Consulte toutes les règles de la liste des règles d'alerte.
Description de l'opération
Cette rubrique fournit un exemple montrant comment consulter toutes les règles d'alerte de la liste des règles d'alerte associée au compte Alibaba Cloud actuel. La réponse indique que la liste des règles d'alerte ne contient qu'une seule règle d'alerte. Le nom de la règle d'alerte est Rule_01 et l'identifiant est applyTemplate344cfd42-0f32-4fd6-805a-88d7908a****.
Testez maintenant
Testez cette API dans OpenAPI Explorer, sans signature manuelle. Les appels réussis génèrent automatiquement du code SDK correspondant à vos paramètres. Téléchargez-le avec une sécurité intégrée des identifiants pour une utilisation locale. Testez cette API dans OpenAPI Explorer, sans signature manuelle. Les appels réussis génèrent automatiquement du code SDK correspondant à vos paramètres. Téléchargez-le avec une sécurité intégrée des identifiants pour une utilisation locale.
Test
Autorisation RAM
|
cms:DescribeMetricRuleList |
get |
*All Resource
|
Aucune | Aucune |
Paramètres de requête
|
Paramètre |
Type |
Requis |
Description |
Exemple |
| MetricName |
string |
Non |
Le nom de la métrique. Pour plus d'informations sur la manière d'obtenir les noms des métriques, consultez DescribeMetricMetaList ou Métriques des services cloud. Remarque : pour les métriques composites, vous ne pouvez rechercher que par la première métrique. |
cpu_total |
| EnableState |
boolean |
Non |
L'état d'activation de la règle d'alerte. Valeurs valides :
|
true |
| Namespace |
string |
Non |
L'espace de noms du service cloud. Pour plus d'informations sur la manière d'obtenir l'espace de noms d'un service cloud, consultez DescribeMetricMetaList ou Métriques des services cloud. |
acs_ecs_dashboard |
| Page |
integer |
Non |
Le numéro de page. |
1 |
| PageSize |
integer |
Non |
Le nombre d'entrées par page. |
10 |
| AlertState |
string |
Non |
L'état de la règle d'alerte. Valeurs valides :\n- OK : Normal.\n- ALARM : Alerte.\n- INSUFFICIENT_DATA : Aucune donnée. |
OK |
| Dimensions |
string |
Non |
Les dimensions de surveillance de la ressource spécifiée. Format : une collection de paires |
{"instanceId":"i-2ze2d6j5uhg20x47****"} |
| RuleName |
string |
Non |
Le nom de la règle d'alerte. |
Rule_01 |
| GroupId |
string |
Non |
L'identifiant du groupe d'applications. Pour plus d'informations sur la manière d'obtenir l'identifiant du groupe d'applications, consultez DescribeMonitorGroups. |
7301**** |
| RuleIds |
string |
Non |
Les identifiants des règles d'alerte. Séparez les identifiants multiples par des virgules (,). Vous pouvez interroger jusqu'à 20 règles d'alerte à la fois. |
applyTemplate344cfd42-0f32-4fd6-805a-88d7908a**** |
Pour plus d'informations sur les paramètres de requête courants, consultez Paramètres courants.
Éléments de réponse
|
Élément |
Type |
Description |
Exemple |
|
object |
Aucun. |
||
| Code |
integer |
Le code d'état HTTP. |
200 |
| Message |
string |
Le message d'erreur. |
La ressource spécifiée est introuvable |
| RequestId |
string |
L'identifiant de la requête. |
386C6712-335F-5054-930A-CC92B851ECBA |
| Total |
string |
Le nombre total d'enregistrements. |
1 |
| Success |
boolean |
Indique si l'opération a réussi. Valeurs valides :
|
true |
| Alarms |
object |
||
| Alarm |
array<object> |
La liste des règles d'alerte. |
|
|
array<object> |
Aucun. |
||
| SilenceTime |
integer |
The mute period. Unit: seconds. Default value: 86400. Minimum value: 3600. If the 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 when an alert is triggered. CloudMonitor pushes alert information to this URL through a POST request. Currently, 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. Valid value: METRIC, indicating a time series metric alert rule. |
METRIC |
| Namespace |
string |
The namespace of the 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 time range 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 aggregation period. |
60 |
| RuleId |
string |
The ID of the alert rule. |
applyTemplate344cfd42-0f32-4fd6-805a-88d7908a**** |
| GroupName |
string |
The name of the application group. Remarque
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 associated with the alert rule. |
[{\"instanceId\":\"i-2ze2d6j5uhg20x47****\"}] |
| Escalations |
object |
The trigger conditions for alerts by severity level. |
|
| Info |
object |
The trigger conditions of Info-level alerts. |
|
| ComparisonOperator |
string |
The comparison operator for Info-level thresholds. Valid values:
|
GreaterThanOrEqualToThreshold |
| PreCondition |
string |
The precondition for Info-level alerts. When the ComparisonOperator parameter is set to year-over-year or period-over-period comparison, this parameter works together with it. 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 10% compared to yesterday. Remarque
$Average in $Average>0 is a placeholder in the format of $monitoring_result_field_value. CloudMonitor replaces it with the corresponding statistical value or original monitoring value. |
$Average>80 |
| Times |
integer |
The consecutive number of times for which the Info-level alert condition is met. An alert is triggered only when the condition is met for the specified consecutive times and the threshold is exceeded. |
3 |
| Threshold |
string |
The threshold for Info-level alerts. |
90 |
| Statistics |
string |
The statistical method for Info-level alerts. |
Average |
| Warn |
object |
The trigger conditions of Warn-level alerts. |
|
| ComparisonOperator |
string |
The comparison operator for Warn-level thresholds. Valid values:
|
GreaterThanOrEqualToThreshold |
| PreCondition |
string |
The precondition for Warn-level alerts. When the ComparisonOperator parameter is set to year-over-year or period-over-period comparison, this parameter works together with it. 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 10% compared to yesterday. Remarque
$Average in $Average>0 is a placeholder in the format of $monitoring_result_field_value. CloudMonitor replaces it with the corresponding statistical value or original monitoring value. |
$Average>80 |
| Times |
integer |
The consecutive number of times for which the Warn-level alert condition is met. An alert is triggered only when the condition is met for the specified consecutive times and the threshold is exceeded. |
3 |
| Threshold |
string |
The threshold for Warn-level alerts. |
90 |
| Statistics |
string |
The statistical method for Warn-level alerts. |
Average |
| Critical |
object |
The trigger conditions of Critical-level alerts. |
|
| ComparisonOperator |
string |
The comparison operator for Critical-level thresholds. Valid values:
|
GreaterThanOrEqualToThreshold |
| PreCondition |
string |
The precondition for Critical-level alerts. When the ComparisonOperator parameter is set to year-over-year or period-over-period comparison, this parameter works together with it. 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 10% compared to yesterday. Remarque
$Average in $Average>0 is a placeholder in the format of |
$Average>80 |
| Times |
integer |
The consecutive number of times for which the Critical-level alert condition is met. An alert is triggered only when the condition is met for the specified consecutive times and the threshold is exceeded. |
3 |
| Threshold |
string |
The threshold for Critical-level alerts. |
90 |
| Statistics |
string |
The statistical method for Critical-level alerts. |
Average |
| NoDataPolicy |
string |
The method to handle alerts when no monitoring data is found. Valid values:
|
KEEP_LAST_STATE |
| CompositeExpression |
object |
The alert conditions for multiple metrics. Remarque
Single-metric and multi-metric 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 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:
Remarque
|
$Maximum |
| ComparisonOperator |
string |
The comparison operator for the threshold. 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 included but not limited to:
|
$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 |
Prometheus alerts. Remarque
This parameter is required only when you create Prometheus alert rules for Enterprise Cloud Monitor. |
|
| PromQL |
string |
The PromQL query statement. Remarque
The data obtained by the PromQL query 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 Prometheus alerts are triggered, the annotation keys and values are rendered to make it easier for you to understand the metrics or alert rules. Remarque
This feature is equivalent to Prometheus Annotations. |
|
|
object |
None. |
||
| Key |
string |
The annotation key. |
summary |
| Value |
string |
The annotation value. |
{{ $labels.instance }} CPU usage above 10% {current value: {{ humanizePercentage $value }} } |
| SendOK |
boolean |
Specifies whether to disable recovery alerts. Valid values: true (yes) and false (no). |
true |
| ProductCategory |
string |
The type of the 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 |
Exemples
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 }} }"
}
]
}
},
"SendOK": true,
"ProductCategory": "slb",
"GmtCreate": 1760432061000,
"GmtUpdate": "1760432061000"
}
]
}
}
Codes d'erreur
|
Code de statut HTTP |
Code d'erreur |
Message d'erreur |
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. |
Consultez Codes d'erreur pour la liste complète.
Notes de version
Consultez Notes de version pour la liste complète.