获取资源报警器历史

GET/zstack/v1/zwatch/alarm-histories

Headers

Authorization: OAuth the-session-uuid

Curl示例

curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X GET http://localhost:8080/zstack/v1/zwatch/alarm-histories?startTime=1.596444525E9&endTime=1.596530925E9&limit=200.0&count=false&excludeOtherAccount=false&start=0.0

参数列表

名字类型位置描述可选值起始版本
startTime (可选)Longquery起始时间 2.3
endTime (可选)Longquery结束时间 2.3
limit (可选)Integerquery返回记录条数数量 2.3
conditions (可选)Listquery条件列表,用于过滤结果 2.3
count (可选)booleanquery是否查询消息数量 3.3.0
excludeOtherAccount (可选)booleanquery是否排除非当前账号的消息(只对SystemAdmin生效) 3.3.0
endpointUuid (可选)Stringquery接收端Uuid 3.10.0
systemTags (可选)Listquery系统标签 2.3
userTags (可选)Listquery用户标签 2.3

API返回

返回示例

{
  "histories": [
    {
      "alarmUuid": "143b24a12d193c1992c4774dc3b34fda",
      "namespace": "ZStack/VM",
      "metricName": "CPUUsedUtilization",
      "accountUuid": "90aea7a1dfe93cf7bd3379254dddbdf9",
      "resourceUuid": "4e6bb5390d3938cb9ce830a4766ee4d8",
      "resourceType": "VmInstanceVO",
      "alarmStatus": "Alarm",
      "alarmName": "test-alarm",
      "threshold": 90.0,
      "labels": "VMUuid Equal 4e6bb5390d3938cb9ce830a4766ee4d8, CPUNum Equal 2",
      "metricValue": 10.0,
      "comparisonOperator": "LessThan",
      "time": 1510669257141.0
    }
  ]
}
名字类型描述起始版本
errorErrorCode错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error2.3
historiesList详情参考histories2.3

error

名字类型描述起始版本
codeString错误码号,错误的全局唯一标识,例如SYS.1000, HOST.10012.3
descriptionString错误的概要描述2.3
detailsString错误的详细信息2.3
elaborationString保留字段,默认为null2.3
opaqueLinkedHashMap保留字段,默认为null2.3
causeErrorCode根错误,引发当前错误的源错误,若无原错误,该字段为null2.3

histories

名字类型描述起始版本
alarmUuidString报警器UUID2.3
namespaceString名字空间名称2.3
metricNameString监控项名称2.3
accountUuidString账户UUID2.3
resourceUuidString资源UUID2.3
resourceTypeString资源类型2.3
alarmStatusString报警器状态2.3
alarmNameString报警器名称2.3
thresholdDouble报警阈值2.3
periodInteger阈值持续周期2.3
labelsString标签列表2.3
metricValueDouble监控项当时值2.3
timelong报警纪录生成时间2.3

SDK示例

Java SDK

GetAlarmDataAction action = new GetAlarmDataAction();
action.startTime = 1.530856218E9;
action.endTime = 1.530942618E9;
action.limit = 200.0;
action.count = false;
action.excludeOtherAccount = false;
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
GetAlarmDataAction.Result res = action.call();

Python SDK

GetAlarmDataAction action = GetAlarmDataAction()
action.startTime = 1.530856218E9
action.endTime = 1.530942618E9
action.limit = 200.0
action.count = false;
action.excludeOtherAccount = false;
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
GetAlarmDataAction.Result res = action.call()