Add Action to Alarm

POST/zstack/v1/zwatch/alarms/{alarmUuid}/actions

Headers

Authorization: OAuth the-session-uuid

Body

{
  "params": {
    "actionUuid": "a48c9fa0454238a4b731279b92d8bad1",
    "actionType": "sns"
  },
  "systemTags": [],
  "userTags": []
}

In the above example, the systemTags and userTags fields can be omitted. They are listed here 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 POST -d '{"params":{"actionUuid":"a48c9fa0454238a4b731279b92d8bad1","actionType":"sns"}}' http://localhost:8080/zstack/v1/zwatch/alarms/3edde2bd29493568a2640f75d218ed05/actions

Parameter List

NameTypeLocationDescriptionAllowed ValuesStarting Version
alarmUuidStringurlAlarm UUID. 2.3
actionUuidStringbody (contained in the params structure)Alarm action UUID. 2.3
actionTypeStringbody (contained in the params structure)Alarm action type. 2.3
systemTags (Optional)ListbodySystem tags. 2.3
userTags (Optional)ListbodyUser tags. 2.3

API Response

Response Example

{
  "inventory": {
    "uuid": "6b9ce7e8a6c04476aa22ce6c851a7f80",
    "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:39 PM",
    "lastOpDate": "Jul 6, 2018 1:50:39 PM",
    "labels": [
      {
        "uuid": "f183fec66c3d40938621568943f4c0bf",
        "key": "VMUuid",
        "operator": "=",
        "value": "7d46ab7f0f104ad0908f23d648bcaa9e"
      }
    ],
    "actions": [
      {
        "alarmUuid": "7379b3951c9f4c82a0571cc55ebc98b3",
        "actionType": "sns",
        "actionUuid": "27e18067eb614fd4bcb047c008e3a4c0"
      }
    ]
  }
}
NameTypeDescriptionStarting Version
errorErrorCodeThe error code. If not null, the operation failed. This field is null on success. See error for details.2.3
inventoryAlarmInventorySee inventory for details.2.3

error

NameTypeDescriptionStarting Version
codeStringThe error code number. A globally unique identifier for the error, for example, SYS.1000, HOST.1001.2.3
descriptionStringA brief description of the error.2.3
detailsStringDetailed information about the error.2.3
elaborationStringA reserved field. Default is null.2.3
opaqueLinkedHashMapA reserved field. Default is null.2.3
causeErrorCodeThe root error. The source error that caused the current error. This field is null if there is no root error.2.3

inventory

NameTypeDescriptionStarting Version
uuidStringThe UUID of the resource. Uniquely identifies the resource.2.3
nameStringResource name.2.3
descriptionStringDetailed description of the resource.2.3
periodIntegerThreshold duration.2.3
namespaceStringNamespace.2.3
metricNameStringMetric name.2.3
thresholdDoubleThreshold.2.3
repeatIntervalIntegerAlarm repeat interval.2.3
createDateTimestampCreation time.2.3
lastOpDateTimestampLast modification time.2.3
comparisonOperatorComparisonOperatorSee comparisonOperator for details.2.3
statusAlarmStatusSee status for details.2.3
labelsListSee labels for details.2.3
actionsListSee actions for details.2.3

comparisonOperator

NameTypeDescriptionStarting Version
nameStringResource name.2.3
ordinalint 2.3

status

NameTypeDescriptionStarting Version
OKAlarmStatusMonitoring.2.3
AlarmAlarmStatusTriggered.2.3
InsufficientDataAlarmStatusInsufficient data.2.3

labels

NameTypeDescriptionStarting Version
uuidStringThe UUID of the resource. Uniquely identifies the resource.2.3
keyStringLabel key.2.3
operatorStringComparison operator.2.3
valueStringLabel value.2.3

actions

NameTypeDescriptionStarting Version
alarmUuidStringAlarm UUID.2.3
actionTypeStringAlarm action type.2.3
actionUuidStringAlarm action UUID.2.3

SDK Examples

Java SDK

AddActionToAlarmAction action = new AddActionToAlarmAction();
action.alarmUuid = "3edde2bd29493568a2640f75d218ed05";
action.actionUuid = "a48c9fa0454238a4b731279b92d8bad1";
action.actionType = "sns";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
AddActionToAlarmAction.Result res = action.call();

Python SDK

AddActionToAlarmAction action = AddActionToAlarmAction()
action.alarmUuid = "3edde2bd29493568a2640f75d218ed05"
action.actionUuid = "a48c9fa0454238a4b731279b92d8bad1"
action.actionType = "sns"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
AddActionToAlarmAction.Result res = action.call()