All Products
Search
Document Center

CloudMonitor:DescribeMetricRuleList

Last Updated:Sep 19, 2024

Queries alert rules.

Operation description

This topic provides an example on how to query all alert rules within your Alibaba Cloud account. The returned result shows that only one alert rule is found. The name of the alert rule is Rule_01 and the ID is applyTemplate344cfd42-0f32-4fd6-805a-88d7908a****.

Debugging

OpenAPI Explorer automatically calculates the signature value. For your convenience, we recommend that you call this operation in OpenAPI Explorer.

Authorization information

The following table shows the authorization information corresponding to the API. The authorization information can be used in the Action policy element to grant a RAM user or RAM role the permissions to call this API operation. Description:

  • Operation: the value that you can use in the Action element to specify the operation on a resource.
  • Access level: the access level of each operation. The levels are read, write, and list.
  • Resource type: the type of the resource on which you can authorize the RAM user or the RAM role to perform the operation. Take note of the following items:
    • The required resource types are displayed in bold characters.
    • If the permissions cannot be granted at the resource level, All Resources is used in the Resource type column of the operation.
  • Condition Key: the condition key that is defined by the cloud service.
  • Associated operation: other operations that the RAM user or the RAM role must have permissions to perform to complete the operation. To complete the operation, the RAM user or the RAM role must have the permissions to perform the associated operations.
OperationAccess levelResource typeCondition keyAssociated operation
cms:DescribeMetricRuleListget
  • All Resources
    *
    none
none

Request parameters

ParameterTypeRequiredDescriptionExample
MetricNamestringNo

The name of the metric.

For information about how to obtain the name of a metric, see DescribeMetricMetaList or Appendix 1: Metrics.

cpu_total
EnableStatebooleanNo

Specifies whether to query enabled or disabled alert rules. Valid values:

  • true: queries enabled alert rules.
  • false: queries disabled alert rules.
true
NamespacestringNo

The namespace of the cloud service.

For information about how to obtain the namespace of a cloud service, see DescribeMetricMetaList or Appendix 1: Metrics.

acs_ecs_dashboard
PageintegerNo

The page number of the page to return.

Minimum value: 1. Default value: 1.

1
PageSizeintegerNo

The number of entries to return on each page.

Minimum value: 1. Default value: 10.

10
AlertStatestringNo

The status of the alert rule. Valid values:

  • OK: The alert rule has no active alerts.
  • ALARM: The alert rule has active alerts.
  • INSUFFICIENT_DATA: No data is available.
OK
DimensionsstringNo

The monitoring dimensions of the specified resource.

Set the value to a collection of key:value pairs. Example: {"userId":"120886317861****"} or {"instanceId":"i-2ze2d6j5uhg20x47****"}.

{"instanceId":"i-2ze2d6j5uhg20x47****"}
RuleNamestringNo

The name of the alert rule.

This parameter supports fuzzy match.

Rule_01
GroupIdstringNo

The ID of the application group.

For information about how to obtain the ID of an application group, see DescribeMonitorGroups .

7301****
RuleIdsstringNo

The ID of the alert rule. You can specify up to 20 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 parameters

ParameterTypeDescriptionExample
object

None.

Codeinteger

The HTTP status code.

Note The status code 200 indicates that the call is successful.
200
Messagestring

The error message.

The specified resource is not found.
RequestIdstring

The ID of the request.

386C6712-335F-5054-930A-CC92B851ECBA
Totalstring

The total number of returned entries.

1
Successboolean

Indicates whether the call is successful. Valid values:

  • true: The call is successful.
  • false: The call fails.
true
Alarmsarray<object>

The alert rules.

object

None.

SilenceTimeinteger

The mute period during which new alert notifications are not sent even if the trigger conditions are met. Unit: seconds. Default value: 86400. Minimum value: 3600.

Only one alert is reported during each mute period even if the metric value consecutively exceeds the alert rule threshold several times.

86400
MetricNamestring

The name of the metric.

cpu_total
Webhookstring

The callback URL. CloudMonitor pushes an alert notification to the specified callback URL by sending an HTTP POST request. Only the HTTP protocol is supported.

https://www.aliyun.com
ContactGroupsstring

The alert contact group.

ECS_Alarm
SourceTypestring

The type of the alert rule. Valid value: METRIC. This value indicates an alert rule for time series metrics.

METRIC
Namespacestring

The namespace of the cloud service.

acs_ecs_dashboard
MailSubjectstring

The subject of the alert notification email.

"${serviceType}-${metricName}-${levelDescription}Notification(${dimensions})"
NoEffectiveIntervalstring

The time period during which the alert rule is ineffective.

00:00-05:30
EffectiveIntervalstring

The time period during which the alert rule is effective.

05:31-23:59
RuleNamestring

The name of the alert rule.

Rule_01
AlertStatestring

The status of the alert rule. Valid values:

  • OK: The alert rule has no active alerts.
  • ALARM: The alert rule has active alerts.
  • INSUFFICIENT_DATA: No data is available.
OK
Periodstring

The statistical period.

60
RuleIdstring

The ID of the alert rule.

applyTemplate344cfd42-0f32-4fd6-805a-88d7908a****
GroupNamestring

The name of the application group.

Note If the alert rule is associated with an application group, the name of the application group is returned in this parameter.
ECS_Group
GroupIdstring

The ID of the application group.

7301****
Dimensionsstring

The dimensions of the alert rule.

[{"instanceId":"i-2ze2d6j5uhg20x47****"}]
EnableStateboolean

Indicates whether the alert rule is enabled. Valid values:

  • true: The alert rule is enabled.
  • false: The alert rule is disabled.
true
Resourcesstring

The resources that are associated with the alert rule.

[{\"instanceId\":\"i-2ze2d6j5uhg20x47****\"}]
Escalationsobject

The conditions for triggering different levels of alerts.

Infoobject

The conditions for triggering Info-level alerts.

ComparisonOperatorstring

The comparison operator that is used to compare the metric value with the threshold. Valid values:

  • GreaterThanOrEqualToThreshold: greater than or equal to the threshold
  • GreaterThanThreshold: greater than the threshold
  • LessThanOrEqualToThreshold: less than or equal to the threshold
  • LessThanThreshold: less than the threshold
  • NotEqualToThreshold: not equal to the threshold
  • GreaterThanYesterday: greater than the metric value at the same time yesterday
  • LessThanYesterday: less than the metric value at the same time yesterday
  • GreaterThanLastWeek: greater than the metric value at the same time last week
  • LessThanLastWeek: less than the metric value at the same time last week
  • GreaterThanLastPeriod: greater than the metric value in the last monitoring cycle
  • LessThanLastPeriod: less than the metric value in the last monitoring cycle
GreaterThanOrEqualToThreshold
PreConditionstring

The additional conditions for triggering Info-level alerts. The additional conditions take effect when the value of the ComparisonOperator parameter is GreaterThanYesterday, LessThanYesterday, GreaterThanLastWeek, LessThanLastWeek, GreaterThanLastPeriod, or LessThanLastPeriod.

For example, the values of the PreCondition, ComparisonOperator, and Threshold parameters are set to $Average>80, GreaterThanYesterday, and 10, respectively. An alert is triggered only when the average metric value is greater than 80 and 10% greater than the average metric value at the same time yesterday.

Note $Average is a placeholder that consists of a dollar sign ($) and the statistical method. CloudMonitor replaces the placeholder with the aggregated value or original value before value comparison.
$Average>80
Timesinteger

The consecutive number of times for which the metric value meets the alert condition before an Info-level alert is triggered.

3
Thresholdstring

The threshold for Info-level alerts.

90
Statisticsstring

The statistical methods for Info-level alerts.

Average
Warnobject

The conditions for triggering Warn-level alerts.

ComparisonOperatorstring

The comparison operator that is used to compare the metric value with the threshold. Valid values:

  • GreaterThanOrEqualToThreshold: greater than or equal to the threshold
  • GreaterThanThreshold: greater than the threshold
  • LessThanOrEqualToThreshold: less than or equal to the threshold
  • LessThanThreshold: less than the threshold
  • NotEqualToThreshold: not equal to the threshold
  • GreaterThanYesterday: greater than the metric value at the same time yesterday
  • LessThanYesterday: less than the metric value at the same time yesterday
  • GreaterThanLastWeek: greater than the metric value at the same time last week
  • LessThanLastWeek: less than the metric value at the same time last week
  • GreaterThanLastPeriod: greater than the metric value in the last monitoring cycle
  • LessThanLastPeriod: less than the metric value in the last monitoring cycle
GreaterThanOrEqualToThreshold
PreConditionstring

The additional conditions for triggering Warn-level alerts. The additional conditions take effect when the value of the ComparisonOperator parameter is GreaterThanYesterday, LessThanYesterday, GreaterThanLastWeek, LessThanLastWeek, GreaterThanLastPeriod, or LessThanLastPeriod.

For example, the values of the PreCondition, ComparisonOperator, and Threshold parameters are set to $Average>80, GreaterThanYesterday, and 10, respectively. An alert is triggered only when the average metric value is greater than 80 and 10% greater than the average metric value at the same time yesterday.

Note $Average is a placeholder that consists of a dollar sign ($) and the statistical method. CloudMonitor replaces the placeholder with the aggregated value or original value before value comparison.
$Average>80
Timesinteger

The consecutive number of times for which the metric value meets the alert condition before a Warn-level alert is triggered.

3
Thresholdstring

The threshold for Warn-level alerts.

90
Statisticsstring

The statistical methods for Warn-level alerts.

Average
Criticalobject

The conditions for triggering Critical-level alerts.

ComparisonOperatorstring

The comparison operator that is used to compare the metric value with the threshold. Valid values:

  • GreaterThanOrEqualToThreshold: greater than or equal to the threshold
  • GreaterThanThreshold: greater than the threshold
  • LessThanOrEqualToThreshold: less than or equal to the threshold
  • LessThanThreshold: less than the threshold
  • NotEqualToThreshold: not equal to the threshold
  • GreaterThanYesterday: greater than the metric value at the same time yesterday
  • LessThanYesterday: less than the metric value at the same time yesterday
  • GreaterThanLastWeek: greater than the metric value at the same time last week
  • LessThanLastWeek: less than the metric value at the same time last week
  • GreaterThanLastPeriod: greater than the metric value in the last monitoring cycle
  • LessThanLastPeriod: less than the metric value in the last monitoring cycle
GreaterThanOrEqualToThreshold
PreConditionstring

The additional conditions for triggering Critical-level alerts. The additional conditions take effect when the value of the ComparisonOperator parameter is GreaterThanYesterday, LessThanYesterday, GreaterThanLastWeek, LessThanLastWeek, GreaterThanLastPeriod, or LessThanLastPeriod.

For example, the values of the PreCondition, ComparisonOperator, and Threshold parameters are set to $Average>80, GreaterThanYesterday, and 10, respectively. An alert is triggered only when the average metric value is greater than 80 and 10% greater than the average metric value at the same time yesterday.

Note $Average is a placeholder that consists of a dollar sign ($) and the statistical method. CloudMonitor replaces the placeholder with the aggregated value or original value before value comparison.
$Average>80
Timesinteger

The consecutive number of times for which the metric value meets the alert condition before a Critical-level alert is triggered.

3
Thresholdstring

The threshold for Critical-level alerts.

90
Statisticsstring

The statistical methods for Critical-level alerts.

Average
NoDataPolicystring

The method that is used to handle alerts when no monitoring data is found. Valid values:

  • KEEP_LAST_STATE (default value): No operation is performed.
  • INSUFFICIENT_DATA: An alert whose content is "Insufficient data" is triggered.
  • OK: The status is considered normal.
KEEP_LAST_STATE
CompositeExpressionobject

The trigger conditions for multiple metrics.

Note The trigger conditions for a single metric and multiple metrics are mutually exclusive. You cannot specify trigger conditions for a single metric and multiple metrics at the same time.
Levelstring

The alert level. Valid values:

  • CRITICAL
  • WARN
  • INFO
Critical
ExpressionListarray<object>

The trigger conditions that are created in standard mode.

object

None.

MetricNamestring

The metric that is used to monitor the cloud service.

cpu_total
Periodinteger

The aggregation period of the metric.

Unit: seconds.

60
Statisticsstring

The statistical method of the metric. Valid values:

  • $Maximum: the maximum value
  • $Minimum: the minimum value
  • $Average: the average value
  • $Availability: the availability rate (usually used for site monitoring)
Note $ is the prefix of the metric. For information about the Alibaba Cloud services that are supported by CloudMonitor, see Appendix 1: Metrics.
$Maximum
ComparisonOperatorstring

The operator that is used to compare the metric value with the threshold. Valid values:

  • GreaterThanOrEqualToThreshold: greater than or equal to the threshold
  • GreaterThanThreshold: greater than the threshold
  • LessThanOrEqualToThreshold: less than or equal to the threshold
  • LessThanThreshold: less than the threshold
  • NotEqualToThreshold: not equal to the threshold
  • GreaterThanYesterday: greater than the metric value at the same time yesterday
  • LessThanYesterday: less than the metric value at the same time yesterday
  • GreaterThanLastWeek: greater than the metric value at the same time last week
  • LessThanLastWeek: less than the metric value at the same time last week
  • GreaterThanLastPeriod: greater than the metric value in the last monitoring cycle
  • LessThanLastPeriod: less than the metric value in the last monitoring cycle
GreaterThanOrEqualToThreshold
Thresholdstring

The alert threshold.

90
ExpressionListJoinstring

The relationship between the trigger conditions for multiple metrics. Valid values:

  • &&: An alert is triggered only if all metrics meet the trigger conditions. An alert is triggered only if the results of all expressions specified in the ExpressionList parameter are true.
  • ||: An alert is triggered if one of the metrics meets the trigger conditions.
||
ExpressionRawstring

The trigger conditions that are created by using expressions. You can use expressions to create trigger conditions in the following scenarios:

  • Set an alert blacklist for specific resources. For example, if you specify $instanceId != 'i-io8kfvcpp7x5****' ``&&`` $Average > 50, no alert is triggered when the average metric value of the i-io8kfvcpp7x5**** instance exceeds 50.
  • Set a special alert threshold for a specified instance in the rule. For example, if you specify $Average > ($instanceId == 'i-io8kfvcpp7x5****'? 80: 50), an alert is triggered when the average metric value of the i-io8kfvcpp7x5**** instance exceeds 80 or the average metric value of other instances exceeds 50.
  • Limit the number of instances whose metric values exceed the threshold. For example, if you specify count($Average > 20) > 3, an alert is triggered only when the number of instances whose average metric value exceeds 20 exceeds three.
$Average > ($instanceId == 'i-io8kfvcpp7x5****'? 80: 50)
Timesinteger

The number of consecutive triggers. If the number of times that the metric values meet the trigger conditions reaches the value of this parameter, CloudMonitor sends alert notifications.

3
Labelsarray<object>

The tags of the alert rule.

object

None.

Keystring

The tag key of the alert rule.

cmsRuleKey
Valuestring

The tag value of the alert rule.

cmsRuleValue
Prometheusobject

The Prometheus alerts.

Note This parameter is required only if you create a Prometheus alert rule for Hybrid Cloud Monitoring.
PromQLstring

The PromQL query statement.

Note The data obtained by using the PromQL query statement is the monitoring data. You must include the alert threshold in this statement.
CpuUsage{instanceId="xxxx"}[1m]>90
Levelstring

The alert level. Valid values:

  • CRITICAL
  • WARN
  • INFO
Critical
Timeslong

The number of consecutive triggers. If the number of times that the metric values meet the trigger conditions reaches the value of this parameter, CloudMonitor sends alert notifications.

3
Annotationsarray<object>

The annotations of the Prometheus alert rule. When a Prometheus alert is triggered, the system renders the annotated keys and values to help you understand the metrics and alert rule.

Note This parameter is equivalent to the annotations parameter of open source Prometheus.
object

None.

Keystring

The key of the annotation.

summary
Valuestring

The value of the annotation.

{{ $labels.instance }} CPU usage above 10% {current value: {{ humanizePercentage $value }} }

Examples

Sample success responses

JSONformat

{
  "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})\"\n",
        "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 }} }"
              }
            ]
          }
        }
      }
    ]
  }
}

Error codes

HTTP status codeError codeError messageDescription
400InvalidParameterThe specified parameter is not valid.-
403InvalidAuthorizationThe Request is not authorization.-
404ResourceNotFoundThe specified resource is not found.The specified resource is not found.
500InternalErrorThe request processing has failed due to some unknown error.-

For a list of error codes, visit the Service error codes.

Change history

Change timeSummary of changesOperation
2023-08-29The Error code has changedView Change Details