Queries a list of all alert rules.
Operation description
This topic provides an example of how to query all alert rules for the current Alibaba Cloud account. In the example, the response shows that only one alert rule is returned. The name of the alert rule is Rule_01 and its ID is applyTemplate344cfd42-0f32-4fd6-805a-88d7908a****.
Try it now
Test
RAM authorization
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 Metrics for Alibaba Cloud services. |
cpu_total |
| EnableState |
boolean |
No |
The status 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 Metrics for Alibaba Cloud services. |
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 status 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. For example: |
{"instanceId":"i-2ze2d6j5uhg20x47****"} |
| RuleName |
string |
No |
The name of the alert rule. This parameter supports fuzzy queries. |
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 alert rule IDs at a time. 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 status code 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 monitoring data continuously exceeds the threshold of the alert rule, 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 CloudMonitor pushes alert notifications. CloudMonitor pushes alert notifications to the specified URL through POST requests. Only the HTTP protocol is supported. |
https://www.aliyun.com |
| ContactGroups |
string |
The alert 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 status 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 status of the alert rule. Valid values:
|
true |
| Resources |
string |
The resources that are associated with the alert rule. |
[{\"instanceId\":\"i-2ze2d6j5uhg20x47****\"}] |
| Escalations |
object |
The conditions for triggering different levels of alerts. |
|
| Info |
object |
The conditions for triggering an Info-level alert. |
|
| ComparisonOperator |
string |
The comparison operator for the threshold of the Info-level alert. 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 comparison with a previous time period. 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 day-over-day increase is 10%. Note
In `$Average>0`, `$Average` is a placeholder in the format of `$Monitoring result field value`. CloudMonitor replaces the placeholder with the corresponding statistical value or the original monitoring value. |
$Average>80 |
| Times |
integer |
The number of consecutive times that the Info-level alert is triggered. An alert is triggered only when 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 threshold of the Warn-level alert. 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 comparison with a previous time period. 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 day-over-day increase is 10%. Note
In `$Average>0`, `$Average` is a placeholder in the format of `$Monitoring result field value`. CloudMonitor replaces the placeholder with the corresponding statistical value or the original monitoring value. |
$Average>80 |
| Times |
integer |
The number of consecutive times that the Warn-level alert is triggered. An alert is triggered only when 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 threshold of the Critical-level alert. 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 comparison with a previous time period. 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 day-over-day increase is 10%. Note
In `$Average>0`, `$Average` is a placeholder in the format of |
$Average>80 |
| Times |
integer |
The number of consecutive times that the Critical-level alert is triggered. An alert is triggered only when 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 conditions for a multi-metric alert rule. Note
Single-metric and multi-metric alert rules are mutually exclusive. You cannot set 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
|
$Maximum |
| ComparisonOperator |
string |
The comparison operator for the threshold. Valid values:
|
GreaterThanOrEqualToThreshold |
| Threshold |
string |
The alert threshold. |
90 |
| ExpressionListJoin |
string |
The relationship between the conditions of the multi-metric alert rule. 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 labels 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 rule. Note
You need to set this parameter only when you create a Prometheus alert rule for Hybrid Cloud Monitoring. |
|
| PromQL |
string |
The Prometheus Query Language (PromQL) search statement. Note
The data that is queried by the PromQL search statement is the monitoring data. The alert threshold must be included in the search 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.