Event

GetAllEventMetadata

API Request

URLs
GET zstack/v1/zwatch/events/meta-data
Headers
Authorization: OAuth the-session-uuid
Curl Example
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
Parameter List
Name Type Location Description Allowed Values Starting Version
name (Optional) String query The event name. 3.9.0
namespace (Optional) String query The event namespace. 3.9.0
systemTags (Optional) List query System tags. 0.6
userTags (Optional) List query User tags. 0.6

API Response

Response Example
{
  "events": [
    {
      "namespace": "ZStack/VM",
      "name": "org.zstack.zwatch.datatype.EventFamily@631b5229",
      "description": "VMHAProcess",
      "labelNames": [
        "HAProcess",
        "HADetails"
      ]
    }
  ]
}
Name Type Description Starting Version
error ErrorCode The error code. If not null, the operation failed. This field is null when the operation succeeds. See error for details. 2.3
events List See events for details. 2.3
#error
Name Type Description Starting Version
code String The error code number. A globally unique identifier for the error, e.g., SYS.1000, HOST.1001. 0.6
description String A brief description of the error. 0.6
details String The detailed error information. 0.6
elaboration String A reserved field. Default is null. 0.6
opaque LinkedHashMap A reserved field. Default is null. 0.6
cause ErrorCode The root error. The source error that caused the current error. This field is null if there is no root cause. 0.6
#events
Name Type Description Starting Version
namespace String The namespace. 2.3
name String The resource name. 2.3
description String The description. 3.9.0
labelNames List The label names. 2.3

SDK Examples

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 Request

URLs
GET zstack/v1/zwatch/events
Headers
Authorization: OAuth the-session-uuid
Curl Example
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
Parameter List
Name Type Location Description Allowed Values Starting Version
startTime (Optional) Long query The start time. 2.3
endTime (Optional) Long query The end time. 2.3
limit (Optional) Integer query The maximum number of returned results. 2.3
offsetAheadOfCurrentTime (Optional) Long query The number of milliseconds before the current time. For example, to query messages from the last hour, pass in 3600000. 3.3.0
conditions (Optional) List query The query conditions. 3.3.0
count (Optional) boolean query Whether to query the event count. 3.3.0
endpointUuid (Optional) String query The endpoint UUID. 3.10.0
systemTags (Optional) List query System tags. 2.3
userTags (Optional) List query User tags. 2.3

API Response

Response Example
{
  "events": [
    {
      "namespace": "ZStack/VM",
      "name": "org.zstack.zwatch.datatype.EventFamily@2c24d960",
      "labels": {},
      "emergencyLevel": "Normal",
      "resourceId": "b7bbe5fb9ab049c5a36bf8a646471cff",
      "resourceName": "VmInstanceVO",
      "time": 1.596444516324E12
    }
  ]
}
Name Type Description Starting Version
total Long The number of events. 3.3.0
success boolean Whether the operation succeeded. 3.3.0
error ErrorCode The error code. If not null, the operation failed. This field is null when the operation succeeds. See error for details. 2.3
events List See events for details. 2.3
#error
Name Type Description Starting Version
code String The error code number. A globally unique identifier for the error, e.g., SYS.1000, HOST.1001. 2.3
description String A brief description of the error. 2.3
details String The detailed error information. 2.3
elaboration String A reserved field. Default is null. 2.3
opaque LinkedHashMap A reserved field. Default is null. 2.3
cause ErrorCode The root error. The source error that caused the current error. This field is null if there is no root cause. 2.3
#events
Name Type Description Starting Version
namespace String The namespace. 2.3
name String The event name. 2.3
labels Map The labels. 2.3
resourceId String The ID of the resource that generated the event. If it is a ZStack ZSphere resource, this is the resource UUID. 2.3
resourceName String The resource name. 2.3
error String If the event represents an error, this field contains the error details. 2.3
time long The time when the event occurred. 2.3
dataUuid String The message UUID. 3.3
accountUuid String The account UUID. 3.3
emergencyLevel EmergencyLevel See emergencyLevel for details. 2.3
#emergencyLevel
Name Type Description Starting Version
name String The resource name. 2.3
ordinal int The ordinal number. 2.3

SDK Examples

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 Request

URLs
PUT zstack/v1/zwatch/events/actions
Headers
Authorization: OAuth the-session-uuid
Body
{
  "updateEventData": {
    "dataUuid": "a24e9918fdf83d0aae19846bd52411e4",
    "updateMode": "OnlyOne",
    "readStatus": "Read"
  },
  "systemTags": [],
  "userTags": []
}
Note: In the above example, the systemTags and userTags fields can be omitted. They are listed to indicate that the body can contain these two fields.
Curl Example
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
Parameter List
Name Type Location Description Allowed Values Starting Version
dataUuid (Optional) String body (contained in the updateEventData structure) The UUID of the resource. Uniquely identifies the resource. 3.3.0
dataStartTime (Optional) Long body (contained in the updateEventData structure) The start time for selecting target messages. The updateMode must be set to InRange. 3.3.0
dataEndTime (Optional) Long body (contained in the updateEventData structure) The end time for selecting target messages. The updateMode must be set to InRange. 3.3.0
updateMode String body (contained in the updateEventData structure) The scope of target messages to update. OnlyOne updates only the specified message, InRange updates messages generated within a specific time range, All updates all messages.
  • OnlyOne
  • InRange
  • All
3.3.0
readStatus (Optional) String body (contained in the updateEventData structure) Updates the read status of the message.
  • Read
  • Unread
3.3.0
systemTags (Optional) List body System tags. 3.3.0
userTags (Optional) List body User tags. 3.3.0

API Response

On success, this API returns an empty JSON structure {}. On failure, the returned JSON structure contains an error field. For example:
{
"error": {
    "code": "SYS.1001",
    "description": "A message or a operation timeout",
    "details": "Create VM on KVM timeout after 300s"
}
}

SDK Examples

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 Request

URLs
GET zstack/v1/zwatch/event-records
Headers
Authorization: OAuth the-session-uuid
Curl Example
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

Queryable Fields

Run the CLI command-line tool, enter QueryEventRecord, and press the Tab key to view all queryable fields and cross-table queryable resource names.

API Response

Response Example
{
  "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\"}"
    }
  ]
}
Name Type Description Starting Version
error ErrorCode The error code. If not null, the operation failed. This field is null when the operation succeeds. See error for details. 4.1.0
inventories List See inventories for details. 4.1.0
#error
Name Type Description Starting Version
code String The error code number. A globally unique identifier for the error, e.g., SYS.1000, HOST.1001. 4.1.0
description String A brief description of the error. 4.1.0
details String The detailed error information. 4.1.0
elaboration String A reserved field. Default is null. 4.1.0
opaque LinkedHashMap A reserved field. Default is null. 4.1.0
cause ErrorCode The root error. The source error that caused the current error. This field is null if there is no root cause. 4.1.0
#inventories
Name Type Description Starting Version
time long The time. 4.1.0
count long The count. 4.1.0
id long The message ID. 4.1.0
createTime long The creation time. 4.1.0
namespace String The namespace. 4.1.0
name String The name. 4.1.0
emergencyLevel String The alarm level. 4.1.0
resourceId String The resource UUID. 4.1.0
error String The error information. 4.1.0
dataUuid String The message UUID. 4.1.0
accountUuid String The account UUID. 4.1.0
subscriptionUuid String The event alarm UUID. 4.1.0
readStatus Boolean The read status. 4.1.0
labels String The label list. 4.1.0

SDK Examples

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()

QueryEventLog

API Request

URLs
GET zstack/v1/eventlogs
GET zstack/v1/eventlogs/{id}
Headers
Authorization: OAuth the-session-uuid
Curl Example
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X GET http://localhost:8080/zstack/v1/eventlogs
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X GET http://localhost:8080/zstack/v1/eventlogs/{id}

Queryable Fields

Run the CLI command-line tool, enter QueryEventLog, and press the Tab key to view all queryable fields and cross-table queryable resource names.

API Response

On success, this API returns an empty JSON structure {}. On failure, the returned JSON structure contains an error field. For example:
{
	"error": {
		"code": "SYS.1001",
		"description": "A message or a operation timeout",
		"details": "Create VM on KVM timeout after 300s"
	}
}

SDK Examples

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()
API Reference | ZStack ZSphere · ZVF | ZStack Resource Center