QueryAlarm

API Request

URLs
GET zstack/v1/zwatch/alarms
GET zstack/v1/zwatch/alarms/{uuid}
Headers
Authorization: OAuth the-session-uuid
Curl Sample
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X GET http://localhost:8080/zstack/v1/zwatch/alarms?q=name=VM
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X GET http://localhost:8080/zstack/v1/zwatch/alarms/572c61c4a1393b6ebce520a0102dc46c

Queryable Fields

You can check all queryable fields and resource names that can be queried across tables by using zstack-cli, entering QueryAlarm, and pressing the Tab key.

API Response

Sample Response
{
  "inventories": [
    {
      "uuid": "5c9ef4b25c2a485da77eab50745d53cf",
      "name": "VM CPU Alarm",
      "comparisonOperator": "LessThanOrEqualTo",
      "period": 60.0,
      "namespace": "ZStack/VM",
      "metricName": "org.zstack.zwatch.datatype.Metric@565e1ebe",
      "threshold": 30.0,
      "repeatInterval": 1800.0,
      "status": "Alarm",
      "state": "Enabled",
      "createDate": "Jul 6, 2018 1:50:51 PM",
      "lastOpDate": "Jul 6, 2018 1:50:51 PM",
      "labels": [
        {
          "uuid": "5ab29656f8df43a3a78d672af8940896",
          "key": "VMUuid",
          "operator": "\u003d",
          "value": "b128326b8b944c0499992c00cabd4711"
        }
      ],
      "actions": [
        {
          "alarmUuid": "2028f51e88b6449fb33442215810845f",
          "actionType": "sns",
          "actionUuid": "9486671b2f4c4413976f1d6938ac1d01"
        }
      ]
    }
  ]
}
Name Type Description Starting Version
error ErrorCode The error code. If not null, the operation fails, or vice versa. For more information, see error. 2.3
inventories List See inventories. 2.3
#error
Name Type Description Starting Version
code String The error code, which is a numbered or alphanumeric code that specifies an error. For example, SYS.1000, HOST.1001. 2.3
description String The brief description of the error. 2.3
details String The details about the error. 2.3
elaboration String The reserved field. Default value: null. 2.3
opaque LinkedHashMap The reserved field. Default value: null. 2.3
cause ErrorCode The root error, which is the associated root cause of the current error. If no root error exists, this parameter is null. 2.3
#inventories
Name Type Description Starting Version
uuid String The resource UUID. 2.3
name String Th resource name. 2.3
description String The detailed description of the resource. 2.3
period Integer The threshold duration. 2.3
namespace String The namespace. 2.3
metricName String The metric name. 2.3
threshold Double The threshold. 2.3
repeatInterval Integer The alarm repeat interval. 2.3
createDate Timestamp The creation date. 2.3
lastOpDate Timestamp The last operation date. 2.3
comparisonOperator ComparisonOperator See comparisonOperator. 2.3
status AlarmStatus See status. 2.3
labels List See labels. 2.3
actions List See actions. 2.3
#comparisonOperator
Name Type Description Starting Version
name String The resource name. 2.3
ordinal int 2.3
#status
Name Type Description Starting Version
OK AlarmStatus The alarm is in normal status. 2.3
Alarm AlarmStatus The alarm is triggered. 2.3
InsufficientData AlarmStatus The data is insufficient. 2.3
#labels
Name Type Description Starting Version
uuid String The resource UUID. 2.3
key String The label key. 2.3
operator String The comparison operator. 2.3
value String The label value. 2.3
#actions
Name Type Description Starting Version
alarmUuid String The alarm UUID. 2.3
actionType String The action type. 2.3
actionUuid String The action UUID. 2.3

SDK Sample

Java SDK
QueryAlarmAction action = new QueryAlarmAction();
action.conditions = asList("name=VM");
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
QueryAlarmAction.Result res = action.call();
Python SDK
QueryAlarmAction action = QueryAlarmAction()
action.conditions = ["name=VM"]
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
QueryAlarmAction.Result res = action.call()