调用DescribeAlertLogList接口查询最近一年的报警历史。
本文将提供一个示例,从云产品product
维度查询云服务器ECS的报警历史。
调试
您可以在OpenAPI Explorer中直接运行该接口,免去您计算签名的困扰。运行成功后,OpenAPI Explorer可以自动生成SDK代码示例。
请求参数
名称 | 类型 | 是否必选 | 示例值 | 描述 |
---|---|---|---|---|
Action | String | 是 | DescribeAlertLogList | 要执行的操作,取值:DescribeAlertLogList。 |
StartTime | Long | 否 | 1609988009694 | 查询报警历史的开始时间戳。 单位:毫秒。 说明
|
EndTime | Long | 否 | 1610074409694 | 查询报警历史的结束时间戳。单位:毫秒。 说明
|
PageNumber | Integer | 否 | 1 | 页码。 默认值:1。 |
PageSize | Integer | 否 | 10 | 分页大小。 默认值:10。 |
SearchKey | String | 否 | alert | 查询报警历史的搜索关键字。 |
GroupId | String | 否 | 7301**** | 应用分组ID。 |
Namespace | String | 否 | acs_ecs_dashboard | 云产品的命名空间。 说明 关于云产品的命名空间,请参见云产品监控项。 |
Product | String | 否 | ECS | 云产品名称缩写。 关于如何获取云产品名称缩写,请参见DescribeProductsOfActiveMetricRule。 |
Level | String | 否 | P4 | 报警的级别和通知方式。取值:
|
SendStatus | String | 否 | 0 | 报警状态。取值:
当报警状态为0时,如果Level的取值为P4,则发生告警;如果Level的取值为OK,则报警恢复正常。 |
ContactGroup | String | 否 | ECS_Group | 报警联系人组。 |
RuleName | String | 否 | test123 | 报警规则名称。 |
MetricName | String | 否 | IntranetInRate | 监控项名称。 说明 关于云产品的监控项,请参见云产品监控项。 |
LastMin | String | 否 | 360 | 获取日志的周期。单位:分钟。 |
GroupBy | String | 否 | product | 对数据进行空间维度聚合,相当于SQL中的Group By。取值:
|
RuleId | String | 否 | bc369e8_30f87e517ed2fc**** | 报警规则ID。 关于如何查询报警规则ID,请参见DescribeMetricRuleList。 |
关于公共请求参数的详情,请参见公共参数。
返回数据
名称 | 类型 | 示例值 | 描述 |
---|---|---|---|
RequestId | String | 1C4A3709-BF52-42EE-87B5-7435F0929585 | 请求ID。 |
Success | Boolean | true | 操作是否成功。取值:
|
Code | String | 200 | 状态码。 说明 200表示成功。 |
Message | String | The specified resource is not found. | 错误信息。 |
PageNumber | Integer | 1 | 页码。 |
PageSize | Integer | 10 | 每页显示记录条数。 |
AlertLogList | Array of Alarm | 报警历史列表。 |
|
MetricName | String | cpu_total | 监控项名称。 |
EventName | String | IOHang | 事件名称。 |
Product | String | ECS | 云产品标识。取值:
|
BlackListUUID | String | 8410dbbd-7d30-41c5-94cb-**** | 命中的报警黑名单UUID。 |
Message | String | {"alertName":"e47aa0ac-4076-44db-a47d-d1083968****_Availability"} | 报警相关信息,为一个JSON串。 |
Namespace | String | acs_ecs_dashboard | 云产品的命名空间。 |
LevelChange | String | P4->OK | 报警级别的变更。取值:
|
InstanceId | String | i-m5e1qg6uo38rztr4**** | 资源ID。 |
RuleName | String | CPU使用率 | 报警规则名称。 |
RuleId | String | d582b9e9-b1c1-4f17-9279-0fe7333a****_ResponseTime | 报警规则ID。 |
BlackListName | String | Black_Test | 命中的报警黑名单名称。 |
GroupName | String | ECS_Instances | 应用分组名称。 |
GroupId | String | 7301**** | 应用分组ID。 |
AlertTime | String | 1610043776621 | 发生报警的时间戳。 单位:毫秒。 |
InstanceName | String | portalHost | 资源名称。 |
BlackListDetail | String | {"id":12****,"metricProject":"acs_ecs_dashboard","userId":173651113438****,"uuid":"8410dbbd-7d30-41c5-94cb-****","name":"alert-****","productCategory":"ecs","instances":[{"instanceId":"i-m5e1qg6uo38rztr4****"}],"metrics":null,"scopeType":"USER","scopeValue":"","startTime":"0001-01-01T00:00:00Z","endTime":"9999-12-31T23:59:59.999999999+08:00","effectiveTime":null,"isEnable":true,"status":1,"gmtCreate":"2021-11-02T16:35:59+08:00","gmtModified":"2021-11-02T16:35:59+08:00","loadTime":"2021-11-02T16:36:15.213072177+08:00"} | 命中的报警黑名单详情。 |
Level | String | P4 | 报警级别和报警通知方式。取值:
|
SendStatus | String | 0 | 报警状态。取值:
当报警状态为0时,如果Level的取值为P4,则发生告警;如果Level的取值为OK,则报警恢复正常。 |
ExtendedInfo | Array of ExtInfo | 报警的扩展信息。 |
|
Name | String | userId | 扩展字段名称。 |
Value | String | 100931896542**** | 扩展字段值。 |
Dimensions | Array of Dimensions | 报警资源的维度。 |
|
Key | String | instanceId | 报警资源的Key。 |
Value | String | i-m5e1qg6uo38rztr4**** | 报警资源的Value。 |
WebhookList | Array of WebhookList | 报警回调的URL地址列表。 |
|
code | String | 200 | 报警回调的状态码。 |
url | String | https://www.aliyun.com/webhook.html | 报警回调的URL地址。 |
message | String | success | 报警回调的返回信息。 |
DingdingWebhookList | Array of String | https://oapi.dingtalk.com/robot/send?access_token=b7ff24032da1a5f86659ecda46797e13cc1d4e4da6903d7b014ea1d1488b**** | 报警联系人的Webhook地址列表。 |
ContactOnCallList | Array of String | 1368888**** | 报警联系人的电话通知列表。 说明 该参数仅适用于中国站。 |
ContactMailList | Array of String | username@example.com | 报警联系人的邮件列表。 |
ContactGroups | Array of String | ECS_Group | 报警联系人组。 |
ContactALIIWWList | Array of String | Alice | 报警联系人的旺旺列表。 说明 该参数仅适用于中国站。 |
ContactSMSList | Array of String | 1368888**** | 报警联系人的短信通知列表。 说明 该参数仅适用于中国站。 |
ContactDingList | Array of String | CloudMonitor | 报警联系人的钉钉列表。 |
SendDetail | Object | 报警推送结果详情。 |
|
ResultCode | String | success | 报警信息推送状态。
|
ChannelResultList | Array of ChannelResult | 按报警渠道推送的报警结果列表。 |
|
Channel | String | 报警推送渠道。取值:
|
|
ResultList | Array of Result | 云监控向报警渠道发送的报警信息结果列表。 |
|
Code | String | 200 | 状态码。
|
RequestId | String | 0BDAF8A8-04DC-5F0C-90E4-724D42C4**** | 调用其他云产品返回的请求ID。 |
Success | Boolean | true | 调用目标的结果
|
Detail | String | { } | 返回结果详情。 |
notifyTargetList | Array of String | 渠道通知列表。 |
|
Escalation | Object | 触发报警的规则。 |
|
Expression | String | $Average<90 | 触发报警的规则描述。 说明 报警规则的主体,当监控数据满足报警条件时,触发报警规则。 |
Times | Integer | 1 | 报警重试次数。 |
Level | String | P4 | 报警级别和报警通知方式。取值:
|
SendResultList | Array of SendResult | 报警的发送结果列表。 |
|
Key | String | 发送报警渠道。取值:
|
|
Value | Array of String | username@example.com | 报警渠道对应的通知对象。 |
LogId | String | 7510****::e8a472a0-46ae-4ac0-84b1-e46be368**** | 日志ID。 |
示例
请求示例
http(s)://[Endpoint]/?Action=DescribeAlertLogList
&Product=ECS
&GroupBy=product
&<公共请求参数>
正常返回示例
XML
格式
HTTP/1.1 200 OK
Content-Type:application/xml
<DescribeAlertLogListResponse>
<AlertLogList>
<GroupName></GroupName>
<Message>{\"alertName\":\"d582b9e9-b1c1-4f17-9279-0fe7333a****_ResponseTime\",\"curLevel\":\"OK\",\"dimensions\":{\"taskId\":\"d582b9e9-b1c1-4f17-9279-0fe7333a****\",\"userId\":\"127067667954****\"},\"escalation\":{\"expression\":\"$Average>=800\",\"level\":P4,\"tag\":\"P4\",\"times\":1}</Message>
<RuleId>d582b9e9-b1c1-4f17-9279-0fe7****_ResponseTime</RuleId>
<Escalation>
<Expression>$Average>=800</Expression>
<Times>1</Times>
<Level>P4</Level>
</Escalation>
<SendStatus>0</SendStatus>
<Product>acs_ecs_dashboard</Product>
<MetricName>cpu_total</MetricName>
<RuleName>CPU使用率</RuleName>
<ContactGroups>ECS_Group</ContactGroups>
<InstanceId></InstanceId>
<LevelChange>P4->OK</LevelChange>
<Dimensions>
<Value>100931896542****</Value>
<Key>userId</Key>
</Dimensions>
<Dimensions>
<Value>i-abcdefgh12****</Value>
<Key>instanceId</Key>
</Dimensions>
<EventName>AlertOk</EventName>
<ExtendedInfo>
<Value>i-hp34y1eiszazu49y****</Value>
<Name>instanceId</Name>
</ExtendedInfo>
<ExtendedInfo>
<Value>12706****</Value>
<Name>userId</Name>
</ExtendedInfo>
<Namespace>acs_ecs_dashboard</Namespace>
<AlertTime>1610085521564</AlertTime>
<GroupId>7301****</GroupId>
<InstanceName>portalHost</InstanceName>
<Level>OK</Level>
</AlertLogList>
<RequestId>6FCB1AB7-57F7-4DDA-B14E-6468FAFE79D9</RequestId>
<PageSize>10</PageSize>
<PageNumber>1</PageNumber>
<Code>200</Code>
<Success>true</Success>
</DescribeAlertLogListResponse>
JSON
格式
HTTP/1.1 200 OK
Content-Type:application/json
{
"AlertLogList" : [ {
"GroupName" : "",
"ContactALIIWWList" : [ ],
"Message" : "{\"alertName\":\"d582b9e9-b1c1-4f17-9279-0fe7333a****_ResponseTime\",\"curLevel\":\"OK\",\"dimensions\":{\"taskId\":\"d582b9e9-b1c1-4f17-9279-0fe7333a****\",\"userId\":\"127067667954****\"},\"escalation\":{\"expression\":\"$Average>=800\",\"level\":P4,\"tag\":\"P4\",\"times\":1}",
"RuleId" : "d582b9e9-b1c1-4f17-9279-0f****_ResponseTime",
"Escalation" : {
"Expression" : "$Average>=800",
"Times" : 1,
"Level" : "P4"
},
"SendStatus" : "0",
"Product" : "acs_ecs_dashboard",
"MetricName" : "cpu_total",
"ContactSMSList" : [ ],
"RuleName" : "CPU使用率",
"ContactGroups" : [ "ECS_Group" ],
"DingdingWebhookList" : [ ],
"InstanceId" : "",
"LevelChange" : "P4->OK",
"Dimensions" : [ {
"Value" : "127067667954****",
"Key" : "userId"
}, {
"Value" : "i-abcdefgh12****",
"Key" : "instanceId"
} ],
"ContactOnCallList" : [ ],
"ContactDingList" : [ ],
"EventName" : "AlertOk",
"ExtendedInfo" : [ {
"Value" : "i-hp34y1eiszazu49y****",
"Name" : "instanceId"
}, {
"Value" : "100931896542****",
"Name" : "userId"
} ],
"Namespace" : "acs_ecs_dashboard",
"AlertTime" : 1610085521564,
"GroupId" : "7301****",
"InstanceName" : "portalHost",
"WebhookList" : [ ],
"ContactMailList" : [ ],
"Level" : "OK"
} ],
"RequestId" : "6FCB1AB7-57F7-4DDA-B14E-6468FAFE79D9",
"PageSize" : 10,
"PageNumber" : 1,
"Code" : 200,
"Success" : true
}
错误码
HttpCode | 错误码 | 错误信息 | 描述 |
---|---|---|---|
404 | ResourceNotFound | The specified resource is not found. | 未找到指定资源。 |
访问错误中心查看更多错误码。