Queries a list of alert rules.
Operation description
This topic provides an example of how to query all alert rules for your Alibaba Cloud account. The response returns one alert rule named Rule_01 with the ID applyTemplate344cfd42-0f32-4fd6-805a-88d7908a****.
Try it now
Test
RAM authorization
|
Action |
Access level |
Resource type |
Condition key |
Dependent action |
|
cms:DescribeMetricRuleList |
get |
*All Resource
|
None | None |
Request parameters
|
Parameter |
Type |
Required |
Description |
Example |
| MetricName |
string |
No |
The name of the metric. For more information about how to obtain the name of a metric, see DescribeMetricMetaList or Cloud service metrics. Note: For composite metrics, you can retrieve them only by the first metric. |
cpu_total |
| EnableState |
boolean |
No |
The state of the alert rule. Valid values:
|
true |
| Namespace |
string |
No |
The namespace of the Alibaba Cloud service. For more information about how to obtain the namespace of an Alibaba Cloud service, see DescribeMetricMetaList or Cloud service metrics. |
acs_ecs_dashboard |
| Page |
integer |
No |
The page number. Starts from 1. Default value: 1. |
1 |
| PageSize |
integer |
No |
The number of entries to return on each page. Starts from 1. Default value: 10. |
10 |
| AlertState |
string |
No |
The state of the alert rule. Valid values:
|
OK |
| Dimensions |
string |
No |
The dimensions that specify the resources to be monitored. The value is a collection of key-value pairs. Format: |
{"instanceId":"i-2ze2d6j5uhg20x47****"} |
| RuleName |
string |
No |
The name of the alert rule. Fuzzy search is supported. |
Rule_01 |
| GroupId |
string |
No |
The ID of the application group. For more information about how to obtain the ID of an application group, see DescribeMonitorGroups. |
7301**** |
| RuleIds |
string |
No |
The ID of the alert rule. You can specify up to 20 IDs. Separate multiple IDs with commas (,). |
applyTemplate344cfd42-0f32-4fd6-805a-88d7908a**** |
For more 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 that the request was successful. |
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 entries. |
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. If the metric value continuously exceeds the alert threshold, an alert notification is sent only once during each mute period. |
86400 |
| MetricName |
string |
The name of the metric. |
cpu_total |
| Webhook |
string |
The callback URL to which alert notifications are sent. CloudMonitor pushes alert notifications to the specified URL through POST requests. Only HTTP is supported. |
https://www.aliyun.com |
| ContactGroups |
string |
The contact group. |
ECS_Alarm |
| SourceType |
string |
The type of the alert rule. The value METRIC 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 notification email. |
"${serviceType}-${metricName}-${levelDescription}通知(${dimensions})" |
| NoEffectiveInterval |
string |
The time period during which the alert rule is ineffective. |
00:00-05:30 |
| EffectiveInterval |
string |
The time period during which the alert rule is effective. |
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 displayed 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 that are associated with the alert rule. |
[{\"instanceId\":\"i-2ze2d6j5uhg20x47****\"}] |
| Escalations |
object |
The conditions for triggering alerts at different levels. |
|
| Info |
object |
The conditions for triggering an Info-level alert. |
|
| ComparisonOperator |
string |
The comparison operator for the Info-level alert threshold. Valid values:
|
GreaterThanOrEqualToThreshold |
| PreCondition |
string |
The precondition for an Info-level alert. This parameter is used with `ComparisonOperator` when `ComparisonOperator` is set to a value that indicates a day-over-day or week-over-week comparison. For example, if you set this parameter to `$Average>80`, `ComparisonOperator` to `GreaterThanYesterday`, and `Threshold` to `10`, an alert is triggered when the average value is greater than 80 and the day-over-day increase is 10%. Note
In `$Average>0`, `$Average` is a placeholder in the `$metric-field-value` format. CloudMonitor replaces it with the corresponding statistical value or the original metric value. |
$Average>80 |
| Times |
integer |
The number of consecutive times that the Info-level alert is triggered. An alert is triggered only if the metric value exceeds the threshold for the specified number of consecutive times. |
3 |
| Threshold |
string |
The threshold for the Info-level alert. |
90 |
| Statistics |
string |
The statistical method for the Info-level alert. |
Average |
| Warn |
object |
The conditions for triggering a Warn-level alert. |
|
| ComparisonOperator |
string |
The comparison operator for the Warn-level alert threshold. Valid values:
|
GreaterThanOrEqualToThreshold |
| PreCondition |
string |
The precondition for a Warn-level alert. This parameter is used with `ComparisonOperator` when `ComparisonOperator` is set to a value that indicates a day-over-day or week-over-week comparison. For example, if you set this parameter to `$Average>80`, `ComparisonOperator` to `GreaterThanYesterday`, and `Threshold` to `10`, an alert is triggered when the average value is greater than 80 and the day-over-day increase is 10%. Note
In `$Average>0`, `$Average` is a placeholder in the `$metric-field-value` format. CloudMonitor replaces it with the corresponding statistical value or the original metric value. |
$Average>80 |
| Times |
integer |
The number of consecutive times that the Warn-level alert is triggered. An alert is triggered only if the metric value exceeds the threshold for the specified number of consecutive times. |
3 |
| Threshold |
string |
The threshold for the Warn-level alert. |
90 |
| Statistics |
string |
The statistical method for the Warn-level alert. |
Average |
| Critical |
object |
The conditions for triggering a Critical-level alert. |
|
| ComparisonOperator |
string |
The comparison operator for the Critical-level alert threshold. Valid values:
|
GreaterThanOrEqualToThreshold |
| PreCondition |
string |
The precondition for a Critical-level alert. This parameter is used with `ComparisonOperator` when `ComparisonOperator` is set to a value that indicates a day-over-day or week-over-week comparison. For example, if you set this parameter to `$Average>80`, `ComparisonOperator` to `GreaterThanYesterday`, and `Threshold` to `10`, an alert is triggered when the average value is greater than 80 and the day-over-day increase is 10%. Note
In `$Average>0`, `$Average` is a placeholder in the |
$Average>80 |
| Times |
integer |
The number of consecutive times that the Critical-level alert is triggered. An alert is triggered only if the metric value exceeds the threshold for the specified number of consecutive times. |
3 |
| Threshold |
string |
The threshold for the Critical-level alert. |
90 |
| Statistics |
string |
The statistical method for the Critical-level alert. |
Average |
| NoDataPolicy |
string |
The method to handle alerts 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. You cannot specify both. |
|
| Level |
string |
The alert level. Valid values:
|
CRITICAL |
| ExpressionList |
object |
||
| ExpressionList |
array<object> |
The list of alert conditions that are created in standard mode. |
|
|
object |
None. |
||
| MetricName |
string |
The name of the metric for the Alibaba Cloud service. |
cpu_total |
| Period |
integer |
The aggregation period of the metric. Unit: seconds. |
60 |
| Statistics |
string |
The statistical method for the metric. Valid values:
Note
The |
$Maximum |
| ComparisonOperator |
string |
The comparison operator for the alert threshold. Valid values:
|
GreaterThanOrEqualToThreshold |
| Threshold |
string |
The alert threshold. |
90 |
| ExpressionListJoin |
string |
The relationship between the alert conditions for multiple metrics. Valid values:
|
|| |
| ExpressionRaw |
string |
The alert conditions that are created using an expression. Examples:
|
$Average > ($instanceId == 'i-io8kfvcpp7x5****'? 80: 50) |
| Times |
integer |
The number of times that the alert condition 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
You must set this parameter only when you create a Prometheus alert rule for Hybrid Cloud Monitoring. |
|
| PromQL |
string |
The Prometheus Query Language (PromQL) query statement. Note
The data that is queried using the PromQL statement is the alert data. Include the alert threshold in the statement. |
CpuUsage{instanceId="xxxx"}[1m]>90 |
| Level |
string |
The alert level. Valid values:
|
CRITICAL |
| Times |
integer |
The number of times that the alert condition must be met before an alert notification is sent. |
3 |
| Annotations |
object |
||
| Annotations |
array<object> |
When a Prometheus alert is triggered, the keys and values of the annotations are rendered to help you understand the metrics or alert rules. Note
This feature is equivalent to the Annotation feature of 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 }} } |
| ProductCategory |
string |
The type of the Alibaba Cloud service. |
slb |
| GmtCreate |
integer |
The time when the rule was created. This value is a UNIX timestamp. |
1760432061000 |
| GmtUpdate |
string |
The time when the rule was updated. This 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}通知(${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. | Parameter error |
| 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. | The specified resource is not found. |
See Error Codes for a complete list.
Release notes
See Release Notes for a complete list.