事件(Event)
获取所有event元数据(GetAllEventMetadata)
API请求
URLs
GET zstack/v1/zwatch/events/meta-dataHeaders
Authorization: OAuth the-session-uuidCurl示例
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X GET http://localhost:8080/zstack/v1/zwatch/events/meta-data?name=VMHAProcess参数列表
| 名字 | 类型 | 位置 | 描述 | 可选值 | 起始版本 |
|---|---|---|---|---|---|
| name (可选) | String | query | 事件名称 | 3.9.0 | |
| namespace (可选) | String | query | 事件命名空间 | 3.9.0 | |
| systemTags (可选) | List | query | 系统标签 | 0.6 | |
| userTags (可选) | List | query | 用户标签 | 0.6 |
API返回
返回示例
{
"events": [
{
"namespace": "ZStack/VM",
"name": "org.zstack.zwatch.datatype.EventFamily@631b5229",
"description": "VMHAProcess",
"labelNames": [
"HAProcess",
"HADetails"
]
}
]
}#error
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| code | String | 错误码号,错误的全局唯一标识,例如SYS.1000, HOST.1001 | 0.6 |
| description | String | 错误的概要描述 | 0.6 |
| details | String | 错误的详细信息 | 0.6 |
| elaboration | String | 保留字段,默认为null | 0.6 |
| opaque | LinkedHashMap | 保留字段,默认为null | 0.6 |
| cause | ErrorCode | 根错误,引发当前错误的源错误,若无原错误,该字段为null | 0.6 |
#events
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| namespace | String | 名字空间 | 2.3 |
| name | String | 资源名称 | 2.3 |
| description | String | 描述 | 3.9.0 |
| labelNames | List | 标签名 | 2.3 |
SDK示例
Java
SDK
GetAllEventMetadataAction action = new GetAllEventMetadataAction();
action.name = "VMHAProcess";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
GetAllEventMetadataAction.Result res = action.call();Python
SDK
GetAllEventMetadataAction action = GetAllEventMetadataAction()
action.name = "VMHAProcess"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
GetAllEventMetadataAction.Result res = action.call()获取事件(GetEventData)
API请求
URLs
GET zstack/v1/zwatch/eventsHeaders
Authorization: OAuth the-session-uuidCurl示例
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X GET http://localhost:8080/zstack/v1/zwatch/events?startTime=1.596444516295E12&limit=10.0&conditions=HostUuid=99ca12b945a8489c93a3412cbc744193&count=false&start=0.0参数列表
| 名字 | 类型 | 位置 | 描述 | 可选值 | 起始版本 |
|---|---|---|---|---|---|
| startTime (可选) | Long | query | 起始时间 | 2.3 | |
| endTime (可选) | Long | query | 结束时间 | 2.3 | |
| limit (可选) | Integer | query | 最大返回条数 | 2.3 | |
| offsetAheadOfCurrentTime (可选) | Long | query | 早于当前时间的毫秒数,例如:查询最近一小时的消息,则传入3600000 | 3.3.0 | |
| conditions (可选) | List | query | 查询条件 | 3.3.0 | |
| count (可选) | boolean | query | 是否查询事件数量 | 3.3.0 | |
| endpointUuid (可选) | String | query | 接收端Uuid | 3.10.0 | |
| systemTags (可选) | List | query | 系统标签 | 2.3 | |
| userTags (可选) | List | query | 用户标签 | 2.3 |
API返回
返回示例
{
"events": [
{
"namespace": "ZStack/VM",
"name": "org.zstack.zwatch.datatype.EventFamily@2c24d960",
"labels": {},
"emergencyLevel": "Normal",
"resourceId": "b7bbe5fb9ab049c5a36bf8a646471cff",
"resourceName": "VmInstanceVO",
"time": 1.596444516324E12
}
]
}| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| total | Long | 事件数目 | 3.3.0 |
| success | boolean | 3.3.0 | |
| error | ErrorCode | 错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error | 2.3 |
| events | List | 详情参考events | 2.3 |
#error
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| code | String | 错误码号,错误的全局唯一标识,例如SYS.1000, HOST.1001 | 2.3 |
| description | String | 错误的概要描述 | 2.3 |
| details | String | 错误的详细信息 | 2.3 |
| elaboration | String | 保留字段,默认为null | 2.3 |
| opaque | LinkedHashMap | 保留字段,默认为null | 2.3 |
| cause | ErrorCode | 根错误,引发当前错误的源错误,若无原错误,该字段为null | 2.3 |
#events
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| namespace | String | 名字空间 | 2.3 |
| name | String | 事件名 | 2.3 |
| labels | Map | 标签 | 2.3 |
| resourceId | String | 产生事件资源的ID(如果为ZStack ZSphere资源则为资源UUID) | 2.3 |
| resourceName | String | 资源名称 | 2.3 |
| error | String | 如果事件代表错误,该字段为错误详情 | 2.3 |
| time | long | 事件产生时间 | 2.3 |
| dataUuid | String | 消息UUID | 3.3 |
| accountUuid | String | 账户UUID | 3.3 |
| emergencyLevel | EmergencyLevel | 详情参考emergencyLevel | 2.3 |
#emergencyLevel
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| name | String | 资源名称 | 2.3 |
| ordinal | int | 2.3 |
SDK示例
Java
SDK
GetEventDataAction action = new GetEventDataAction();
action.startTime = 1.596444516404E12;
action.limit = 10.0;
action.conditions = asList("HostUuid=00d80d7c47124d6d8e2c7736e9af1c34");
action.count = false;
action.start = 0.0;
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
GetEventDataAction.Result res = action.call();Python
SDK
GetEventDataAction action = GetEventDataAction()
action.startTime = 1.596444516405E12
action.limit = 10.0
action.conditions = [HostUuid=7581302347d0439fbdde32b914e2449a]
action.count = false
action.start = 0.0
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
GetEventDataAction.Result res = action.call()更新事件消息(UpdateEventData)
API请求
URLs
PUT zstack/v1/zwatch/events/actionsHeaders
Authorization: OAuth the-session-uuidBody
{
"updateEventData": {
"dataUuid": "a24e9918fdf83d0aae19846bd52411e4",
"updateMode": "OnlyOne",
"readStatus": "Read"
},
"systemTags": [],
"userTags": []
}Note: 上述示例中systemTags、userTags字段可以省略。列出是为了表示body中可以包含这两个字段。
Curl示例
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X PUT -d '{"updateEventData":{"dataUuid":"a24e9918fdf83d0aae19846bd52411e4","updateMode":"OnlyOne","readStatus":"Read"}}' http://localhost:8080/zstack/v1/zwatch/events/actions参数列表
| 名字 | 类型 | 位置 | 描述 | 可选值 | 起始版本 |
|---|---|---|---|---|---|
| dataUuid (可选) | String | body(包含在updateEventData结构中) | 资源的UUID,唯一标示该资源 | 3.3.0 | |
| dataStartTime (可选) | Long | body(包含在updateEventData结构中) | 选择目标消息的起始时间,updateMode需要传入InRange | 3.3.0 | |
| dataEndTime (可选) | Long | body(包含在updateEventData结构中) | 选择目标消息的结束时间,updateMode需要传入InRange | 3.3.0 | |
| updateMode | String | body(包含在updateEventData结构中) | 选择更新目标消息的范围,OnlyOne表示只更新指定的消息,InRange表示更新某个时间范围产生的消息, All表示更新所有消息 |
|
3.3.0 |
| readStatus (可选) | String | body(包含在updateEventData结构中) | 更新消息已读状态 |
|
3.3.0 |
| systemTags (可选) | List | body | 系统标签 | 3.3.0 | |
| userTags (可选) | List | body | 用户标签 | 3.3.0 |
API返回
该API成功时返回一个空的JSON结构
{},出错时返回的JSON结构包含一个error字段,例如:{
"error": {
"code": "SYS.1001",
"description": "A message or a operation timeout",
"details": "Create VM on KVM timeout after 300s"
}
}SDK示例
Java
SDK
UpdateEventDataAction action = new UpdateEventDataAction();
action.dataUuid = "a24e9918fdf83d0aae19846bd52411e4";
action.updateMode = "OnlyOne";
action.readStatus = "Read";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
UpdateEventDataAction.Result res = action.call();Python
SDK
UpdateEventDataAction action = UpdateEventDataAction()
action.dataUuid = "a24e9918fdf83d0aae19846bd52411e4"
action.updateMode = "OnlyOne"
action.readStatus = "Read"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
UpdateEventDataAction.Result res = action.call()查询事件报警器报警记录(QueryEventRecord)
API请求
URLs
GET zstack/v1/zwatch/event-recordsHeaders
Authorization: OAuth the-session-uuidCurl示例
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X GET http://localhost:8080/zstack/v1/zwatch/event-records?q=dataUuid=bcb5816592553e04a101e37c69d1837a可查询字段
运行CLI命令行工具,输入QueryEventRecord并按Tab键查看所有可查询字段以及可跨表查询的资源名。
API返回
返回示例
{
"inventories": [
{
"id": 1.0,
"createTime": 1.510669257141E12,
"namespace": "ZStack/PrimaryStorage",
"name": "PrimaryStorageDisconnected",
"emergencyLevel": "Emergent",
"resourceId": "ff1d1d9429da35cfb3d4dfad772d0f3a",
"dataUuid": "64f3d04e7144348db07585dfc9293582",
"accountUuid": "1f2c621ce02d37268da28bb368f6b265",
"subscriptionUuid": "e30c7668d9c13585915da7e6442f6749",
"readStatus": true,
"labels": "{\"Error\":\"No Host state is Enabled, Please check the availability of the host\"}"
}
]
}| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| error | ErrorCode | 错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error | 4.1.0 |
| inventories | List | 详情参考inventories | 4.1.0 |
#error
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| code | String | 错误码号,错误的全局唯一标识,例如SYS.1000, HOST.1001 | 4.1.0 |
| description | String | 错误的概要描述 | 4.1.0 |
| details | String | 错误的详细信息 | 4.1.0 |
| elaboration | String | 保留字段,默认为null | 4.1.0 |
| opaque | LinkedHashMap | 保留字段,默认为null | 4.1.0 |
| cause | ErrorCode | 根错误,引发当前错误的源错误,若无原错误,该字段为null | 4.1.0 |
#inventories
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| time | long | 时间 | 4.1.0 |
| count | long | 数量 | 4.1.0 |
| id | long | 消息ID | 4.1.0 |
| createTime | long | 创建时间 | 4.1.0 |
| namespace | String | 名字空间 | 4.1.0 |
| name | String | 名称 | 4.1.0 |
| emergencyLevel | String | 报警等级 | 4.1.0 |
| resourceId | String | 资源UUID | 4.1.0 |
| error | String | 错误信息 | 4.1.0 |
| dataUuid | String | 消息UUID | 4.1.0 |
| accountUuid | String | 账户UUID | 4.1.0 |
| subscriptionUuid | String | 事件报警器UUID | 4.1.0 |
| readStatus | Boolean | 已读状态 | 4.1.0 |
| labels | String | 标签列表 | 4.1.0 |
SDK示例
Java
SDK
QueryEventRecordAction action = new QueryEventRecordAction();
action.conditions = asList("dataUuid=1e5badf2a4a43bae91b16dbd1aee0c0b");
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
QueryEventRecordAction.Result res = action.call();Python
SDK
QueryEventRecordAction action = QueryEventRecordAction()
action.conditions = ["dataUuid=60290f65736a317cb52b0721d90ce315"]
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
QueryEventRecordAction.Result res = action.call()查询Event Log(QueryEventLog)
API请求
URLs
GET zstack/v1/eventlogs
GET zstack/v1/eventlogs/{id}Headers
Authorization: OAuth the-session-uuidCurl示例
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X GET http://localhost:8080/zstack/v1/eventlogscurl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X GET http://localhost:8080/zstack/v1/eventlogs/{id}可查询字段
运行CLI命令行工具,输入QueryEventLog并按Tab键查看所有可查询字段以及可跨表查询的资源名。
API返回
该API成功时返回一个空的JSON结构
{},出错时返回的JSON结构包含一个error字段,例如:{
"error": {
"code": "SYS.1001",
"description": "A message or a operation timeout",
"details": "Create VM on KVM timeout after 300s"
}
}SDK示例
Java
SDK
QueryEventLogAction action = new QueryEventLogAction();
action.conditions = asList();
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
QueryEventLogAction.Result res = action.call();Python
SDK
QueryEventLogAction action = QueryEventLogAction()
action.conditions = []
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
QueryEventLogAction.Result res = action.call()