Queries all alert rules in the alert rule list.
Operation description
This topic provides an example of how to query all alert rules in the alert rule list of the current Alibaba Cloud account. The response shows that the alert rule list contains only one alert rule. The alert rule is named Rule_01 and has an ID of applyTemplate344cfd42-0f32-4fd6-805a-88d7908a****.
Try it now
Test
RAM authorization
|
Action |
Access level |
Resource type |
Condition key |
Dependent action |
|
cms:DescribeMetricRuleList |
get |
*全部资源
|
None | None |
Request parameters
|
Parameter |
Type |
Required |
Description |
Example |
| MetricName |
string |
No |
The metric name. For information about how to obtain metric names, see DescribeMetricMetaList or cloud service monitoring metrics. Note: For composite metrics, you can retrieve results only by the first metric. |
cpu_total |
| EnableState |
boolean |
No |
The enabled state of the alert rule. Valid values:
|
true |
| Namespace |
string |
No |
The namespace of the Alibaba Cloud service. For information about how to obtain the namespace of an Alibaba Cloud service, see DescribeMetricMetaList or cloud service monitoring metrics. |
acs_ecs_dashboard |
| Page |
integer |
No |
The page number. Minimum value: 1. Default value: 1. |
1 |
| PageSize |
integer |
No |
The number of entries per page. Minimum value: 1. Default value: 10. |
10 |
| AlertState |
string |
No |
The state of the alert rule. Valid values:
|
OK |
| Dimensions |
string |
No |
The monitoring dimensions of the specified resource. Format: a collection of |
{"instanceId":"i-2ze2d6j5uhg20x47****"} |
| RuleName |
string |
No |
The name of the alert rule. This parameter supports fuzzy match. |
Rule_01 |
| GroupId |
string |
No |
The ID of the application group. For information about how to obtain the application group ID, see DescribeMonitorGroups. |
7301**** |
| RuleIds |
string |
No |
The IDs of the alert rules. Separate multiple IDs with commas (,). You can query up to 20 alert rules at a time. |
applyTemplate344cfd42-0f32-4fd6-805a-88d7908a**** |
For information about common request parameters, see Common parameters.
Response elements
|
Element |
Type |
Description |
Example |
|
object |
None. |
||
| Code |
integer |
The status code. Note
A value of 200 indicates success. |
200 |
| Message |
string |
The error message. |
The specified resource is not found. |
| RequestId |
string |
The request ID. |
386C6712-335F-5054-930A-CC92B851ECBA |
| Total |
string |
The total number of records. |
1 |
| Success |
boolean |
Indicates whether the operation was successful. Valid values:
|
true |
| Alarms |
object |
||
| Alarm |
array<object> |
The list of alert rules. |
|
|
array<object> |
None. |
||
| SilenceTime |
integer |
The mute period. Unit: seconds. Default value: 86400. Minimum value: 3600. When monitoring data continuously exceeds the alert rule threshold, only one alert notification is sent within each mute period. |
86400 |
| MetricName |
string |
The metric name. |
cpu_total |
| Webhook |
string |
The callback URL to which CloudMonitor sends alert notifications by using POST requests. Only HTTP is supported. |
https://www.aliyun.com |
| ContactGroups |
string |
The alert contact group. |
ECS_Alarm |
| SourceType |
string |
The type of the alert rule. Valid values: METRIC, which indicates a time series metric alert rule. |
METRIC |
| Namespace |
string |
The namespace of the Alibaba Cloud service. |
acs_ecs_dashboard |
| MailSubject |
string |
The subject of the alert email. |
"${serviceType}-${metricName}-${levelDescription} notification(${dimensions})" |
| NoEffectiveInterval |
string |
The time range during which the alert rule is ineffective. |
00:00-05:30 |
| EffectiveInterval |
string |
The effective period of the alert rule. |
05:31-23:59 |
| RuleName |
string |
The name of the alert rule. |
Rule_01 |
| AlertState |
string |
The state of the alert rule. Valid values:
|
OK |
| Period |
string |
The statistical period. |
60 |
| RuleId |
string |
The ID of the alert rule. |
applyTemplate344cfd42-0f32-4fd6-805a-88d7908a**** |
| GroupName |
string |
The name of the application group. Note
This parameter is returned only if the alert rule is associated with an application group. |
ECS_Group |
| GroupId |
string |
The ID of the application group. |
7301**** |
| Dimensions |
string |
The dimensions of the alert rule. |
[{"instanceId":"i-2ze2d6j5uhg20x47****"}] |
| EnableState |
boolean |
The enabled state. Valid values:
|
true |
| Resources |
string |
The resources associated with the alert rule. |
[{\"instanceId\":\"i-2ze2d6j5uhg20x47****\"}] |
| Escalations |
object |
The conditions that trigger alerts at different levels. |
|
| Info |
object |
The conditions that trigger Info-level alerts. |
|
| ComparisonOperator |
string |
The comparison operator for Info-level thresholds. Valid values:
|
GreaterThanOrEqualToThreshold |
| PreCondition |
string |
The precondition for Info-level alerts. This parameter works together with the ComparisonOperator parameter when ComparisonOperator is set to a year-over-year or period-over-period comparison. For example, if this parameter is set to $Average>80, ComparisonOperator is set to GreaterThanYesterday, and Threshold is set to 10, an alert is triggered when the average value is greater than 80 and the value has increased by more than 10% compared with yesterday. Note
$Average in $Average>0 is a placeholder in the format of $monitoring result field value. CloudMonitor replaces it with the corresponding statistical value or raw monitoring value. |
$Average>80 |
| Times |
integer |
The number of consecutive occurrences of Info-level alerts. An alert is triggered only when the threshold is exceeded for this number of consecutive times. |
3 |
| Threshold |
string |
The threshold for Info-level alerts. |
90 |
| Statistics |
string |
The statistical method for Info-level alerts. |
Average |
| Warn |
object |
The conditions that trigger Warn-level alerts. |
|
| ComparisonOperator |
string |
The comparison operator for Warn-level thresholds. Valid values:
|
GreaterThanOrEqualToThreshold |
| PreCondition |
string |
The precondition for Warn-level alerts. This parameter works together with the ComparisonOperator parameter when ComparisonOperator is set to a year-over-year or period-over-period comparison. For example, if this parameter is set to $Average>80, ComparisonOperator is set to GreaterThanYesterday, and Threshold is set to 10, an alert is triggered when the average value is greater than 80 and the value has increased by more than 10% compared with yesterday. Note
$Average in $Average>0 is a placeholder in the format of $monitoring result field value. CloudMonitor replaces it with the corresponding statistical value or raw monitoring value. |
$Average>80 |
| Times |
integer |
The number of consecutive occurrences of Warn-level alerts. An alert is triggered only when the threshold is exceeded for this number of consecutive times. |
3 |
| Threshold |
string |
The threshold for Warn-level alerts. |
90 |
| Statistics |
string |
The statistical method for Warn-level alerts. |
Average |
| Critical |
object |
The conditions that trigger Critical-level alerts. |
|
| ComparisonOperator |
string |
The comparison operator for Critical-level thresholds. Valid values:
|
GreaterThanOrEqualToThreshold |
| PreCondition |
string |
The precondition for Critical-level alerts. This parameter works together with the ComparisonOperator parameter when ComparisonOperator is set to a year-over-year or period-over-period comparison. For example, if this parameter is set to $Average>80, ComparisonOperator is set to GreaterThanYesterday, and Threshold is set to 10, an alert is triggered when the average value is greater than 80 and the value has increased by more than 10% compared with yesterday. Note
$Average in $Average>0 is a placeholder in the format of |
$Average>80 |
| Times |
integer |
The number of consecutive occurrences of Critical-level alerts. An alert is triggered only when the threshold is exceeded for this number of consecutive times. |
3 |
| Threshold |
string |
The threshold for Critical-level alerts. |
90 |
| Statistics |
string |
The statistical method for Critical-level alerts. |
Average |
| NoDataPolicy |
string |
The processing method when no monitoring data is available. Valid values:
|
KEEP_LAST_STATE |
| CompositeExpression |
object |
The alert conditions for multiple metrics. Note
Single-metric and multi-metric alert conditions are mutually exclusive and cannot be set at the same time. |
|
| Level |
string |
The alert level. Valid values:
|
CRITICAL |
| ExpressionList |
object |
||
| ExpressionList |
array<object> |
The list of alert conditions created in standard mode. |
|
|
object |
None. |
||
| MetricName |
string |
The metric name of the Alibaba Cloud service. |
cpu_total |
| Period |
integer |
The aggregation period of the metric. Unit: seconds. |
60 |
| Statistics |
string |
The statistical method of the metric. Valid values:
Note
|
$Maximum |
| ComparisonOperator |
string |
The comparison operator for thresholds. Valid values:
|
GreaterThanOrEqualToThreshold |
| Threshold |
string |
The alert threshold. |
90 |
| ExpressionListJoin |
string |
The relationship between multi-metric alert conditions. Valid values:
|
|| |
| ExpressionRaw |
string |
The alert conditions created by using expressions. The following scenarios are supported but not limited to:
|
$Average > ($instanceId == 'i-io8kfvcpp7x5****'? 80: 50) |
| Times |
integer |
The number of times that the alert conditions must be met before an alert notification is sent. |
3 |
| Labels |
object |
||
| Labels |
array<object> |
The tags of the alert rule. |
|
|
object |
None. |
||
| Key |
string |
The tag key of the alert rule. |
cmsRuleKey |
| Value |
string |
The tag value of the alert rule. |
cmsRuleValue |
| Prometheus |
object |
The Prometheus alert. Note
Set this parameter only when you create a Prometheus alert rule for Hybrid Cloud Monitoring. |
|
| PromQL |
string |
The PromQL query statement. Note
The data retrieved by the PromQL query statement is the alert data. Include the alert threshold in this statement. |
CpuUsage{instanceId="xxxx"}[1m]>90 |
| Level |
string |
The alert level. Valid values:
|
CRITICAL |
| Times |
integer |
The number of times that the alert conditions must be met before an alert notification is sent. |
3 |
| Annotations |
object |
||
| Annotations |
array<object> |
The annotations for Prometheus alerts. The keys and values of annotations are rendered to help you understand the metrics or alert rules. Note
This feature is equivalent to the Annotation feature in Prometheus. |
|
|
object |
None. |
||
| Key |
string |
The key of the annotation. |
summary |
| Value |
string |
The value of the annotation. |
{{ $labels.instance }} CPU usage above 10% {current value: {{ humanizePercentage $value }} } |
| SendOK |
boolean |
是否关闭恢复告警。取值:true(是)、false(否)。 |
true |
| ProductCategory |
string |
The type of the Alibaba Cloud service. |
slb |
| GmtCreate |
integer |
The time when the rule was created. The value is a UNIX timestamp. |
1760432061000 |
| GmtUpdate |
string |
The time when the rule was last updated. The value is a UNIX timestamp. |
1760432061000 |
Examples
Success response
JSON format
{
"Code": 200,
"Message": "The specified resource is not found.",
"RequestId": "386C6712-335F-5054-930A-CC92B851ECBA",
"Total": "1",
"Success": true,
"Alarms": {
"Alarm": [
{
"SilenceTime": 86400,
"MetricName": "cpu_total",
"Webhook": "https://www.aliyun.com",
"ContactGroups": "ECS_Alarm",
"SourceType": "METRIC",
"Namespace": "acs_ecs_dashboard",
"MailSubject": "\"${serviceType}-${metricName}-${levelDescription} notification(${dimensions})\"",
"NoEffectiveInterval": "00:00-05:30",
"EffectiveInterval": "05:31-23:59",
"RuleName": "Rule_01",
"AlertState": "OK",
"Period": "60",
"RuleId": "applyTemplate344cfd42-0f32-4fd6-805a-88d7908a****",
"GroupName": "ECS_Group",
"GroupId": "7301****",
"Dimensions": "[{\"instanceId\":\"i-2ze2d6j5uhg20x47****\"}]",
"EnableState": true,
"Resources": "[{\\\"instanceId\\\":\\\"i-2ze2d6j5uhg20x47****\\\"}]",
"Escalations": {
"Info": {
"ComparisonOperator": "GreaterThanOrEqualToThreshold",
"PreCondition": "$Average>80",
"Times": 3,
"Threshold": "90",
"Statistics": "Average"
},
"Warn": {
"ComparisonOperator": "GreaterThanOrEqualToThreshold",
"PreCondition": "$Average>80",
"Times": 3,
"Threshold": "90",
"Statistics": "Average"
},
"Critical": {
"ComparisonOperator": "GreaterThanOrEqualToThreshold",
"PreCondition": "$Average>80",
"Times": 3,
"Threshold": "90",
"Statistics": "Average"
}
},
"NoDataPolicy": "KEEP_LAST_STATE",
"CompositeExpression": {
"Level": "CRITICAL",
"ExpressionList": {
"ExpressionList": [
{
"MetricName": "cpu_total",
"Period": 60,
"Statistics": "$Maximum",
"ComparisonOperator": "GreaterThanOrEqualToThreshold",
"Threshold": "90"
}
]
},
"ExpressionListJoin": "||",
"ExpressionRaw": "$Average > ($instanceId == 'i-io8kfvcpp7x5****'? 80: 50)",
"Times": 3
},
"Labels": {
"Labels": [
{
"Key": "cmsRuleKey",
"Value": "cmsRuleValue"
}
]
},
"Prometheus": {
"PromQL": "CpuUsage{instanceId=\"xxxx\"}[1m]>90",
"Level": "CRITICAL",
"Times": 3,
"Annotations": {
"Annotations": [
{
"Key": "summary",
"Value": "{{ $labels.instance }} CPU usage above 10% {current value: {{ humanizePercentage $value }} }"
}
]
}
},
"ProductCategory": "slb",
"GmtCreate": 1760432061000,
"GmtUpdate": "1760432061000"
}
]
}
}
Error codes
|
HTTP status code |
Error code |
Error message |
Description |
|---|---|---|---|
| 400 | InvalidParameter | Invalid parameter. | 参数错误 |
| 500 | InternalError | The request processing has failed due to some unknown error. | |
| 403 | InvalidAuthorization | The Request is not authorization. | |
| 404 | ResourceNotFound | The specified resource is not found. | 未找到指定资源。 |
See Error Codes for a complete list.
Release notes
See Release Notes for a complete list.