Consulta todas as regras na lista de regras de alerta.
Descrição da operação
Este tópico fornece um exemplo de como consultar todas as regras de alerta na lista de regras de alerta sob a conta Alibaba Cloud atual. A resposta mostra que a lista de regras de alerta contém apenas uma regra de alerta. O nome da regra de alerta é Rule_01 e o ID é applyTemplate344cfd42-0f32-4fd6-805a-88d7908a****.
Experimente agora
Testar
Autorização RAM
|
Ação |
Nível de acesso |
Tipo de recurso |
Chave de condição |
Ação dependente |
|
cms:DescribeMetricRuleList |
get |
*All Resource
|
Nenhuma | Nenhuma |
Parâmetros da solicitação
|
Parâmetro |
Tipo |
Obrigatório |
Descrição |
Exemplo |
| MetricName |
string |
Não |
O nome da métrica. Para informações sobre como obter nomes de métricas, consulte DescribeMetricMetaList ou Métricas de serviços em nuvem. Observação: Para métricas compostas, você só pode pesquisar pela primeira métrica. |
cpu_total |
| EnableState |
boolean |
Não |
O estado de habilitação da regra de alerta. Valores válidos:
|
true |
| Namespace |
string |
Não |
O namespace do serviço em nuvem. Para informações sobre como obter o namespace de um serviço em nuvem, consulte DescribeMetricMetaList ou Métricas de serviços em nuvem. |
acs_ecs_dashboard |
| Page |
integer |
Não |
O número da página. Valor mínimo: 1. Valor padrão: 1. |
1 |
| PageSize |
integer |
Não |
O número de entradas por página. Valor mínimo: 1. Valor padrão: 10. |
10 |
| AlertState |
string |
Não |
O status da regra de alerta. Valores válidos:
|
OK |
| Dimensions |
string |
Não |
As dimensões de monitoramento do recurso especificado. Formato: Uma coleção de pares |
{"instanceId":"i-2ze2d6j5uhg20x47****"} |
| RuleName |
string |
Não |
O nome da regra de alerta. Este parâmetro suporta pesquisa difusa. |
Rule_01 |
| GroupId |
string |
Não |
O ID do grupo de aplicações. Para informações sobre como obter o ID do grupo de aplicações, consulte DescribeMonitorGroups. |
7301**** |
| RuleIds |
string |
Não |
Os IDs das regras de alerta. Separe múltiplos IDs com vírgulas (,). Você pode consultar até 20 regras de alerta por vez. |
applyTemplate344cfd42-0f32-4fd6-805a-88d7908a**** |
Para mais informações sobre parâmetros de solicitação comuns, consulte Parâmetros comuns.
Elementos de resposta
|
Elemento |
Tipo |
Descrição |
Exemplo |
|
object |
Nenhum. |
||
| Code |
integer |
O código de status HTTP. Nota
200 indica sucesso. |
200 |
| Message |
string |
A mensagem de erro. |
The specified resource is not found. |
| RequestId |
string |
O ID da solicitação. |
386C6712-335F-5054-930A-CC92B851ECBA |
| Total |
string |
O número total de registros. |
1 |
| Success |
boolean |
Indica se a operação foi bem-sucedida. Valores válidos:
|
true |
| Alarms |
object |
||
| Alarm |
array<object> |
A lista de regras de alerta. |
|
|
array<object> |
Nenhum. |
||
| 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. Nota
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. Nota
$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. Nota
$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. Nota
$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. Nota
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:
Nota
|
$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. Nota
This parameter is required only when you create Prometheus alert rules for Enterprise Cloud Monitor. |
|
| PromQL |
string |
The PromQL query statement. Nota
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. Nota
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 |
Exemplos
Resposta de sucesso
JSON formato
{
"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"
}
]
}
}
Códigos de erro
|
Código de status HTTP |
Código de erro |
Mensagem de erro |
Descrição |
|---|---|---|---|
| 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. |
Consulte Códigos de Erro para uma lista completa.
Notas de versão
Consulte Notas de Versão para uma lista completa.