Queries alert rules.
This topic provides an example on how to query all alert rules within your Alibaba
Cloud account. The returned result shows that only one alert rule is found. The name
of the alert rule is Rule_01
and the ID is applyTemplate344cfd42-0f32-4fd6-805a-88d7908a****
.
Debugging
Request parameters
Parameter | Type | Required | Example | Description |
---|---|---|---|---|
Action | String | Yes | DescribeMetricRuleList |
The operation that you want to perform. Set the value to DescribeMetricRuleList. |
Namespace | String | No |
The namespace of the cloud service. For information about how to obtain the namespace of a cloud service, see DescribeMetricMetaList or Metrics. |
|
MetricName | String | No |
The name of the metric. For information about how to obtain the name of a metric, see DescribeMetricMetaList or Metrics. |
|
EnableState | Boolean | No | true |
Specifies whether to query enabled or disabled alert rules. Valid values:
|
Page | Integer | No | 1 |
The number of the page to return. Pages start from page 1. Default value: 1. |
PageSize | Integer | No | 10 |
The number of entries to return on each page. A minimum of 1 entry can be returned on each page. Default value: 10. |
AlertState | String | No | OK |
The status of the alert rule. Valid values:
|
Dimensions | String | No | {"instanceId":"i-2ze2d6j5uhg20x47****"} |
The dimensions of the alert rule. The dimensions specify the resources for which you want to query monitoring data. Set the value to a set of key-value pairs, for example, |
RuleName | String | No | Rule_01 |
The name of the alert rule. This parameter supports fuzzy match. |
GroupId | String | No | 7301**** |
The ID of the application group. For information about how to obtain the ID of an application group, see DescribeMonitorGroups. |
RuleIds | String | No | applyTemplate344cfd42-0f32-4fd6-805a-88d7908a**** |
The ID of the alert rule. You can specify up to 20 IDs at a time. Separate multiple IDs with commas (,). |
For more information about common request parameters, see Common parameters.
Response parameters
Parameter | Type | Example | Description |
---|---|---|---|
RequestId | String | 386C6712-335F-5054-930A-CC92B851ECBA |
The ID of the request. |
Code | Integer | 200 |
The HTTP status code. Note The status code 200 indicates that the call was successful.
|
Total | String | 1 |
The total number of returned entries. |
Success | Boolean | true |
Indicates whether the call was successful. Valid values:
|
Alarms | Array of Alarm |
The details of the alert rules. |
|
Alarm | |||
AlertState | String | OK |
The status of the alert rule. Valid values:
|
ContactGroups | String | ECS_Alarm |
The alert contact group. |
Dimensions | String | [{"instanceId":"i-2ze2d6j5uhg20x47****"}] |
The dimensions of the alert rule. |
EffectiveInterval | String | 05:31-23:59 |
The time period during which the alert rule is effective. |
EnableState | Boolean | true |
Indicates whether the alert rule is enabled. Valid values:
|
Escalations | Struct |
The conditions for triggering different levels of alerts. |
|
Critical | Struct |
The conditions for triggering Critical-level alerts. |
|
ComparisonOperator | String |
The comparison operator of the threshold for Critical-level alerts. Valid values:
|
|
PreCondition | String | $Average>80 |
The additional conditions for triggering Critical-level alerts. The additional conditions take effect when the value of the ComparisonOperator parameter is GreaterThanYesterday, LessThanYesterday, GreaterThanLastWeek, LessThanLastWeek, GreaterThanLastPeriod, or LessThanLastPeriod. For example, the values of the PreCondition, ComparisonOperator, and Threshold parameters are set to $Average>80, GreaterThanYesterday, and 10. An alert is triggered only when the average metric value is greater than 80 and 10% greater than the average metric value at the same time yesterday. Note $Average is a placeholder that consists of
a dollar sign ($) and the statistical method . CloudMonitor replaces the placeholder with the aggregated value or original value
before value comparison.
|
Statistics | String |
The statistical methods for Critical-level alerts. |
|
Threshold | String |
The threshold for Critical-level alerts. |
|
Times | Integer | 3 |
The consecutive number of times for which the metric value meets the alert condition before a Critical-level alert is triggered. |
Info | Struct |
The conditions for triggering Info-level alerts. |
|
ComparisonOperator | String |
The comparison operator of the threshold for Info-level alerts. Valid values:
|
|
PreCondition | String | $Average>80 |
The additional conditions for triggering Info-level alerts. The additional conditions take effect when the value of the ComparisonOperator parameter is GreaterThanYesterday, LessThanYesterday, GreaterThanLastWeek, LessThanLastWeek, GreaterThanLastPeriod, or LessThanLastPeriod. For example, the values of the PreCondition, ComparisonOperator, and Threshold parameters are set to $Average>80, GreaterThanYesterday, and 10. An alert is triggered only when the average metric value is greater than 80 and 10% greater than the average metric value at the same time yesterday. Note $Average is a placeholder that consists of
a dollar sign ($) and the statistical method . CloudMonitor replaces the placeholder with the aggregated value or original value
before value comparison.
|
Statistics | String |
The statistical methods for Info-level alerts. |
|
Threshold | String |
The threshold for Info-level alerts. |
|
Times | Integer | 3 |
The consecutive number of times for which the metric value meets the alert condition before an Info-level alert is triggered. |
Warn | Struct |
The conditions for triggering Warn-level alerts. |
|
ComparisonOperator | String |
The comparison operator of the threshold for Warn-level alerts. Valid values:
|
|
PreCondition | String | $Average>80 |
The additional conditions for triggering Warn-level alerts. The additional conditions take effect when the value of the ComparisonOperator parameter is GreaterThanYesterday, LessThanYesterday, GreaterThanLastWeek, LessThanLastWeek, GreaterThanLastPeriod, or LessThanLastPeriod. For example, the values of the PreCondition, ComparisonOperator, and Threshold parameters are set to $Average>80, GreaterThanYesterday, and 10. An alert is triggered only when the average metric value is greater than 80 and 10% greater than the average metric value at the same time yesterday. Note $Average is a placeholder that consists of
a dollar sign ($) and the statistical method . CloudMonitor replaces the placeholder with the aggregated value or original value
before value comparison.
|
Statistics | String |
The statistical methods for Warn-level alerts. |
|
Threshold | String |
The threshold for Warn-level alerts. |
|
Times | Integer | 3 |
The consecutive number of times for which the metric value meets the alert condition before a Warn-level alert is triggered. |
GroupId | String | 7301**** |
The ID of the application group. |
GroupName | String |
The name of the application group. Note If the alert rule is associated with an application group, the name of the application
group is returned in this parameter.
|
|
Labels | Array of Labels |
The tags of the alert rule. |
|
Labels | |||
Key | String | cmsRuleKey |
The tag key of the alert rule. |
Value | String | cmsRuleValue |
The tag value of the alert rule. |
MailSubject | String | "${serviceType}-${metricName}-${levelDescription}Notification (${dimensions})" |
The subject of the alert notification email. |
MetricName | String |
The name of the metric. |
|
Namespace | String |
The namespace of the cloud service. |
|
NoDataPolicy | String |
The method that is used to handle alerts when no monitoring data is found. Valid values:
|
|
NoEffectiveInterval | String | 00:00-05:30 |
The time period during which the alert rule is ineffective. |
Period | String |
The statistical period. |
|
Resources | String | [{\"instanceId\":\"i-2ze2d6j5uhg20x47****\"}] |
The resources that are associated with the alert rule. |
RuleId | String | applyTemplate344cfd42-0f32-4fd6-805a-88d7908a**** |
The ID of the alert rule. |
RuleName | String | Rule_01 |
The name of the alert rule. |
SilenceTime | Integer |
The mute period during which new alerts are not sent even if the trigger conditions are met. Unit: seconds. Default value: 86400. Minimum value: 3600. Only one alert is reported during each mute period even if the metric value consecutively exceeds the alert rule threshold several times. |
|
SourceType | String | METRIC |
The type of the alert rule. Valid value: METRIC. This value indicates an alert rule for time series metrics. |
Webhook | String | https://www.aliyun.com |
The callback URL. CloudMonitor pushes an alert notification to the specified callback URL by sending an HTTP POST request. Only the HTTP protocol is supported. |
Message | String | The specified resource is not found. |
The error message. |
Examples
Sample requests
http(s)://[Endpoint]/?Action=DescribeMetricRuleList
&<Common request parameters>
Sample success responses
XML
format
<DescribeMetricRuleListResponse>
<RequestId>386C6712-335F-5054-930A-CC92B851ECBA</RequestId>
<Total>1</Total>
<Alarms>
<Alarm>
<GroupName>ECS_Group</GroupName>
<SilenceTime>86400</SilenceTime>
<ContactGroups>ECS_Alarm</ContactGroups>
<NoEffectiveInterval>00:00-05:30</NoEffectiveInterval>
<GroupBy>group</GroupBy>
<MailSubject>${serviceType}-${metricName}-${levelDescription}Notification(${dimensions})</MailSubject>
<SourceType>METRIC</SourceType>
<RuleId>applyTemplate344cfd42-0f32-4fd6-805a-88d7908a****</RuleId>
<Period>60</Period>
<Dimensions>
<instanceId>i-2ze2d6j5uhg20x47****</instanceId>
</Dimensions>
<EffectiveInterval>05:31-23:59</EffectiveInterval>
<Namespace>acs_ecs_dashboard</Namespace>
<AlertState>OK</AlertState>
<GroupId>7301****</GroupId>
<MetricName>cpu_total</MetricName>
<EnableState>true</EnableState>
<Escalations>
<Critical>
<ComparisonOperator>GreaterThanOrEqualToThreshold</ComparisonOperator>
<Times>3</Times>
<Statistics>Average</Statistics>
<Threshold>90</Threshold>
</Critical>
<Info>
<ComparisonOperator>GreaterThanOrEqualToThreshold</ComparisonOperator>
<Times>3</Times>
<Statistics>Average</Statistics>
<Threshold>90</Threshold>
</Info>
<Warn>
<ComparisonOperator>GreaterThanOrEqualToThreshold</ComparisonOperator>
<Times>3</Times>
<Statistics>Average</Statistics>
<Threshold>90</Threshold>
</Warn>
</Escalations>
<Webhook>https://www.aliyun.com</Webhook>
<Resources>[{\"instanceId\":\"i-2ze2d6j5uhg20x47****\"}]</Resources>
<RuleName>Rule_01</RuleName>
</Alarm>
</Alarms>
<Code>200</Code>
<Success>true</Success>
</DescribeMetricRuleListResponse>
JSON
format
{
"RequestId": "386C6712-335F-5054-930A-CC92B851ECBA",
"Total": 1,
"Alarms": {
"Alarm": [
{
"GroupName": "ECS_Group",
"SilenceTime": 86400,
"ContactGroups": "ECS_Alarm",
"NoEffectiveInterval": "00:00-05:30",
"GroupBy": "group",
"MailSubject": "${serviceType}-${metricName}-${levelDescription}Notification(${dimensions})",
"SourceType": "METRIC",
"RuleId": "applyTemplate344cfd42-0f32-4fd6-805a-88d7908a****",
"Period": 60,
"Dimensions": [
{
"instanceId": "i-2ze2d6j5uhg20x47****"
}
],
"EffectiveInterval": "05:31-23:59",
"Namespace": "acs_ecs_dashboard",
"AlertState": "OK",
"GroupId": "7301****",
"MetricName": "cpu_total",
"EnableState": true,
"Escalations": {
"Critical": {
"ComparisonOperator": "GreaterThanOrEqualToThreshold",
"Times": 3,
"Statistics": "Average",
"Threshold": "90"
},
"Info": {
"ComparisonOperator": "GreaterThanOrEqualToThreshold",
"Times": 3,
"Statistics": "Average",
"Threshold": "90"
},
"Warn": {
"ComparisonOperator": "GreaterThanOrEqualToThreshold",
"Times": 3,
"Statistics": "Average",
"Threshold": "90"
}
},
"Webhook": "https://www.aliyun.com",
"Resources": "[{\"instanceId\":\"i-2ze2d6j5uhg20x47****\"}]",
"RuleName": "Rule_01"
}
]
},
"Code": "200",
}
Error codes
HttpCode | Error code | Error message | Description |
---|---|---|---|
ResourceNotFound | The specified resource is not found. | The error message returned because the specified resource is not found. |
For a list of error codes, visit the API Error Center.