Event query API
The event query service provides resources for getting, searching, and counting events, and for getting event frequency over time. To update the status or annotations of an existing event, use the event management service.
Resource list
The event query service provides the following resources:
Get an event (GET /v1/events/{id})
Search events (POST /v1/events:search)
Count events (POST /v1/events:count)
Get event frequency (POST /v1/events:frequency)
GET /v1/events/{id}
Get one event by its ID.
Request parameters
The following table describes the path and query parameters for a request to get an event:
Field | Type | Required | Description |
|---|---|---|---|
| string | No | A query parameter that specifies one or more occurrence IDs. When you omit this parameter, the most recent occurrence is returned. To request more than one occurrence, repeat the parameter, for example: |
| string | No | A query parameter that specifies the name of a field to include in the response. When you omit this parameter, all fields are returned. To request more than one field, repeat the parameter. |
| string | Yes | A path parameter that specifies the ID of the event to get. |
Response codes
Code | Description |
|---|---|
200 | The request was processed successfully. For operations on multiple objects, check the response body for per-item results. |
400 | The request couldn't be processed. The request body is missing, malformed, or contains invalid values. |
401 | Authentication failed. The API key is missing or invalid. |
500 | An unexpected error occurred. Try the request again. If the problem persists, contact Virtana support. |
Request example
curl https://YOUR-API-ENDPOINT/v1/events/AAAABWRDWOPER3lzOFI2tSCG49g= \ -H "zenoss-api-key: YOUR-API-KEY"
Response example
{
"result": {
"id": "AAAABWRDWOPER3lzOFI2tSCG49g=",
"entity": "/entities/example-host-01",
"name": "high-cpu",
"count": 1,
"occurrences": [
{
"id": "9f3a2c1d-7e4b-4a9f-8d2e-1b5c6f0e3a7d",
"eventId": "AAAABWRDWOPER3lzOFI2tSCG49g=",
"severity": "SEVERITY_ERROR",
"status": "STATUS_OPEN",
"summary": "CPU usage exceeded 90% for 5 minutes",
"startTime": "1748000000000",
"lastSeen": "1748003600000"
}
]
}
}POST /v1/events:search
Search for events by filter, time range, severity, and status. The results support sorting and pagination.
Request template
An abstract preview of a JSON request to search for events.
{
"query": {
"timeRange": {
"start": <ms-since-epoch>,
"end": <ms-since-epoch>
},
"clause": {
"filter": {
"field": "<field-name>",
"operation": "<operation>",
"value": "<value>"
}
},
"severities": ["<severity>"],
"statuses": ["<status>"],
"sortBy": [
{ "byField": { "field": "<field-name>", "order": "<sort-order>" } }
],
"pageInput": {
"limit": <integer>,
"cursor": "<cursor>",
"direction": "<direction>"
},
"activeCriteria": "<active-criteria>",
"fields": [
{ "field": "<field-name>" }
]
}
}Request fields
The following table describes the fields in a request to search for events:
Field | Type | Required | Description |
|---|---|---|---|
| object | Yes | The search criteria. |
| object | No | The time range to search. |
| integer | No | The start of the time range, specified as milliseconds since the epoch (January 1, 1970 at 00:00:00 UTC). |
| integer | No | The end of the time range, specified as milliseconds since the epoch (January 1, 1970 at 00:00:00 UTC). |
| object | No | A filter clause to apply to event fields. To combine clauses, nest them with the
Supported values for |
| array | No | The event severities to match. When you specify more than one value, events that match any of the values are returned. Accepted values:
|
| array | No | The event statuses to match. When you specify more than one value, events that match any of the values are returned. Accepted values:
|
| array | No | The sort criteria. Criteria are applied in order of decreasing priority. |
| object | No | Sorts results by the value of a field. |
| string | No | The name of the field to sort by, for example, |
| string | No | The sort order. Accepted values:
|
| object | No | The pagination controls. |
| integer | No | The maximum number of results to return per page. When you omit this field, a system-defined limit applies. |
| string | No | The pagination cursor. To get the next page, use the |
| string | No | The pagination direction. Default:
|
| string | No | Determines which occurrences are considered active within the time range. Default:
|
| array | No | The fields to include in each result. When you omit this field, all fields are returned. |
| string | No | The name of a field to include, for example, |
Response codes
Code | Description |
|---|---|
200 | The request was processed successfully. For operations on multiple objects, check the response body for per-item results. |
400 | The request couldn't be processed. The request body is missing, malformed, or contains invalid values. |
401 | Authentication failed. The API key is missing or invalid. |
500 | An unexpected error occurred. Try the request again. If the problem persists, contact Virtana support. |
Request example
curl https://YOUR-API-ENDPOINT/v1/events:search \
-H "content-type: application/json" \
-H "zenoss-api-key: YOUR-API-KEY" \
-X POST -s -S -d \
'{
"query": {
"timeRange": {
"start": "1748000000000",
"end": "1748003600000"
},
"clause": {
"filter": {
"field": "source-type",
"operation": "OP_EQUALS",
"value": "cz"
}
},
"severities": ["SEVERITY_ERROR", "SEVERITY_CRITICAL"],
"statuses": ["STATUS_OPEN"],
"fields": [
{ "field": "eventClass" }
],
"sortBy": [
{ "byField": { "field": "lastSeen", "order": "SORT_ORDER_DESC" } }
],
"pageInput": { "limit": 25 }
}
}'Response example
{
"results": [
{
"id": "AAAABWRDWOPER3lzOFI2tSCG49g=",
"entityName": "example-host-01",
"name": "high-cpu",
"occurrences": [
{
"id": "9f3a2c1d-7e4b-4a9f-8d2e-1b5c6f0e3a7d",
"instanceCount": 1,
"severity": "SEVERITY_ERROR",
"status": "STATUS_OPEN",
"summary": "CPU usage exceeded 90% for 5 minutes",
"lastSeen": "1748003600000",
"coreProperties": {
"eventClass": ["/Perf/CPU"]
}
}
]
}
],
"pageInfo": {
"count": "1",
"totalCount": "1",
"hasNext": false,
"hasPrev": false,
"endCursor": "eyJpZCI6IkFBQUFCV..."
}
}POST /v1/events:count
Count the events that match a query. You can group the counts by the values of one or more fields.
Request template
An abstract preview of a JSON request to count events.
{
"query": { ... },
"fields": [
{ "field": "<group-by-field>" }
],
"countInstances": <boolean>
}Request fields
The following table describes the fields in a request to count events:
Field | Type | Required | Description |
|---|---|---|---|
| object | No | The search criteria. When you omit this field, all events are counted. This field uses the same structure as the |
| array | No | The fields to group the counts by. When you omit this field, a single total count is returned. |
| string | No | The name of a field to group by, for example, |
| boolean | No | Count individual occurrence instances ( |
Response codes
Code | Description |
|---|---|
200 | The request was processed successfully. For operations on multiple objects, check the response body for per-item results. |
400 | The request couldn't be processed. The request body is missing, malformed, or contains invalid values. |
401 | Authentication failed. The API key is missing or invalid. |
500 | An unexpected error occurred. Try the request again. If the problem persists, contact Virtana support. |
Request example
curl https://YOUR-API-ENDPOINT/v1/events:count \
-H "content-type: application/json" \
-H "zenoss-api-key: YOUR-API-KEY" \
-X POST -s -S -d \
'{
"query": {
"timeRange": {
"start": "1748000000000",
"end": "1748003600000"
},
"statuses": ["STATUS_OPEN"]
},
"fields": [
{ "field": "severity" }
]
}'Response example
{
"results": {
"severity": {
"values": [
{ "value": 3, "count": "32" },
{ "value": 4, "count": "17" },
{ "value": 5, "count": "4" }
]
}
}
}Note
The event query service returns grouped field values in the results object as integers, not as enumeration names. Use the following mappings to interpret them:
severity: 0 isSEVERITY_DEFAULT, 1 isSEVERITY_DEBUG, 2 isSEVERITY_INFO, 3 isSEVERITY_WARNING, 4 isSEVERITY_ERROR, and 5 isSEVERITY_CRITICAL.status: 0 isSTATUS_DEFAULT, 1 isSTATUS_OPEN, 2 isSTATUS_SUPPRESSED, and 3 isSTATUS_CLOSED.
POST /v1/events:frequency
Get a time series of event counts over the time range of a query. You can group the time series by field values and combine the counts into larger time intervals.
Request template
An abstract preview of a JSON request to get event frequency.
{
"query": { ... },
"fields": [
{ "field": "<field-name>" }
],
"groupBy": [
{ "field": "<group-by-field>" }
],
"downsample": <milliseconds>,
"countInstances": <boolean>
}Request fields
The following table describes the fields in a request to get event frequency:
Field | Type | Required | Description |
|---|---|---|---|
| object | Yes | The search criteria. This field uses the same structure as the |
| object | Yes | The time range of the time series. Event frequency requests always require a time range. |
| array | Yes | The fields to include in the results. |
| string | Yes | The name of a field to include, for example, |
| array | Yes | The fields to group the time series by. |
| string | Yes | The name of a field to group by, for example, |
| integer | No | The bucket size, in milliseconds. When you specify a value, the counts within each bucket are combined. For example, |
| boolean | No | Count individual occurrence instances ( |
Response codes
Code | Description |
|---|---|
200 | The request was processed successfully. For operations on multiple objects, check the response body for per-item results. |
400 | The request couldn't be processed. The request body is missing, malformed, or contains invalid values. |
401 | Authentication failed. The API key is missing or invalid. |
500 | An unexpected error occurred. Try the request again. If the problem persists, contact Virtana support. |
Request example
curl https://YOUR-API-ENDPOINT/v1/events:frequency \
-H "content-type: application/json" \
-H "zenoss-api-key: YOUR-API-KEY" \
-X POST -s -S -d \
'{
"query": {
"timeRange": {
"start": "1782416198966",
"end": "1782419798966"
},
"clause": {
"filter": {
"field": "source-type",
"operation": "OP_EQUALS",
"value": "cz"
}
}
},
"fields": [
{ "field": "severity" }
],
"groupBy": [
{ "field": "severity" }
],
"downsample": 900000
}'Response example
{
"timestamps": [
"1782416198966",
"1782417098966",
"1782417998966",
"1782418898966"
],
"results": {
"severity": {
"values": [
{ "value": 5, "counts": ["276", "276", "276", "276"] },
{ "value": 4, "counts": ["757", "757", "757", "757"] },
{ "value": 3, "counts": ["62", "64", "64", "81" ] }
]
}
}
}Note
The event query service returns grouped field values in the results object as integers, not as enumeration names. Use the following mappings to interpret them:
severity: 0 isSEVERITY_DEFAULT, 1 isSEVERITY_DEBUG, 2 isSEVERITY_INFO, 3 isSEVERITY_WARNING, 4 isSEVERITY_ERROR, and 5 isSEVERITY_CRITICAL.status: 0 isSTATUS_DEFAULT, 1 isSTATUS_OPEN, 2 isSTATUS_SUPPRESSED, and 3 isSTATUS_CLOSED.