DescribeMetricRuleList

更新时间:
复制 MD 格式

Queries all alert rules in the alert rule list.

Operation description

This topic provides an example of how to query all alert rules in the alert rule list of the current Alibaba Cloud account. The response shows that the alert rule list contains only one alert rule. The alert rule is named Rule_01 and has an ID of applyTemplate344cfd42-0f32-4fd6-805a-88d7908a****.

Try it now

Try this API in OpenAPI Explorer, no manual signing needed. Successful calls auto-generate SDK code matching your parameters. Download it with built-in credential security for local usage.

Test

RAM authorization

The table below describes the authorization required to call this API. You can define it in a Resource Access Management (RAM) policy. The table's columns are detailed below:

  • Action: The actions can be used in the Action element of RAM permission policy statements to grant permissions to perform the operation.

  • API: The API that you can call to perform the action.

  • Access level: The predefined level of access granted for each API. Valid values: create, list, get, update, and delete.

  • Resource type: The type of the resource that supports authorization to perform the action. It indicates if the action supports resource-level permission. The specified resource must be compatible with the action. Otherwise, the policy will be ineffective.

    • For APIs with resource-level permissions, required resource types are marked with an asterisk (*). Specify the corresponding Alibaba Cloud Resource Name (ARN) in the Resource element of the policy.

    • For APIs without resource-level permissions, it is shown as All Resources. Use an asterisk (*) in the Resource element of the policy.

  • Condition key: The condition keys defined by the service. The key allows for granular control, applying to either actions alone or actions associated with specific resources. In addition to service-specific condition keys, Alibaba Cloud provides a set of common condition keys applicable across all RAM-supported services.

  • Dependent action: The dependent actions required to run the action. To complete the action, the RAM user or the RAM role must have the permissions to perform all dependent actions.

Action

Access level

Resource type

Condition key

Dependent action

cms:DescribeMetricRuleList

get

*全部资源

*

None None

Request parameters

Parameter

Type

Required

Description

Example

MetricName

string

No

The metric name.

For information about how to obtain metric names, see DescribeMetricMetaList or cloud service monitoring metrics.

Note: For composite metrics, you can retrieve results only by the first metric.

cpu_total

EnableState

boolean

No

The enabled state of the alert rule. Valid values:

  • true: enabled.

  • false: disabled.

true

Namespace

string

No

The namespace of the Alibaba Cloud service.

For information about how to obtain the namespace of an Alibaba Cloud service, see DescribeMetricMetaList or cloud service monitoring metrics.

acs_ecs_dashboard

Page

integer

No

The page number.

Minimum value: 1. Default value: 1.

1

PageSize

integer

No

The number of entries per page.

Minimum value: 1. Default value: 10.

10

AlertState

string

No

The state of the alert rule. Valid values:

  • OK: Normal.

  • ALARM: Alert.

  • INSUFFICIENT_DATA: No data.

OK

Dimensions

string

No

The monitoring dimensions of the specified resource.

Format: a collection of key:value pairs. Example: {"userId":"120886317861****"} and {"instanceId":"i-2ze2d6j5uhg20x47****"}.

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

RuleName

string

No

The name of the alert rule.

This parameter supports fuzzy match.

Rule_01

GroupId

string

No

The ID of the application group.

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

7301****

RuleIds

string

No

The IDs of the alert rules. Separate multiple IDs with commas (,). You can query up to 20 alert rules at a time.

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

For 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 success.

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 records.

1

Success

boolean

Indicates whether the operation was successful. Valid values:

  • true: The operation was successful.

  • false: The operation failed.

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.

When 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 to which CloudMonitor sends alert notifications by using POST requests. Only HTTP is supported.

https://www.aliyun.com

ContactGroups

string

The alert contact group.

ECS_Alarm

SourceType

string

The type of the alert rule. Valid values: METRIC, which 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 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 effective period of the alert rule.

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: Normal.

  • ALARM: Alert.

  • INSUFFICIENT_DATA: No data.

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 returned only 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: enabled.

  • false: disabled.

true

Resources

string

The resources associated with the alert rule.

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

Escalations

object

The conditions that trigger alerts at different levels.

Info

object

The conditions that trigger Info-level alerts.

ComparisonOperator

string

The comparison operator for Info-level thresholds. 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 value at the same time yesterday.

  • LessThanYesterday: less than the value at the same time yesterday.

  • GreaterThanLastWeek: greater than the value at the same time last week.

  • LessThanLastWeek: less than the value at the same time last week.

  • GreaterThanLastPeriod: greater than the value in the last period.

  • LessThanLastPeriod: less than the value in the last period.

GreaterThanOrEqualToThreshold

PreCondition

string

The precondition for Info-level alerts. This parameter works together with the ComparisonOperator parameter when ComparisonOperator is set to a year-over-year or period-over-period comparison.

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 more than 10% compared with yesterday.

Note

$Average in $Average>0 is a placeholder in the format of $monitoring result field value. CloudMonitor replaces it with the corresponding statistical value or raw monitoring value.

$Average>80

Times

integer

The number of consecutive occurrences of Info-level alerts. An alert is triggered only when the threshold is exceeded for this number of consecutive times.

3

Threshold

string

The threshold for Info-level alerts.

90

Statistics

string

The statistical method for Info-level alerts.

Average

Warn

object

The conditions that trigger Warn-level alerts.

ComparisonOperator

string

The comparison operator for Warn-level thresholds. 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 value at the same time yesterday.

  • LessThanYesterday: less than the value at the same time yesterday.

  • GreaterThanLastWeek: greater than the value at the same time last week.

  • LessThanLastWeek: less than the value at the same time last week.

  • GreaterThanLastPeriod: greater than the value in the last period.

  • LessThanLastPeriod: less than the value in the last period.

GreaterThanOrEqualToThreshold

PreCondition

string

The precondition for Warn-level alerts. This parameter works together with the ComparisonOperator parameter when ComparisonOperator is set to a year-over-year or period-over-period comparison.

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 more than 10% compared with yesterday.

Note

$Average in $Average>0 is a placeholder in the format of $monitoring result field value. CloudMonitor replaces it with the corresponding statistical value or raw monitoring value.

$Average>80

Times

integer

The number of consecutive occurrences of Warn-level alerts. An alert is triggered only when the threshold is exceeded for this number of consecutive times.

3

Threshold

string

The threshold for Warn-level alerts.

90

Statistics

string

The statistical method for Warn-level alerts.

Average

Critical

object

The conditions that trigger Critical-level alerts.

ComparisonOperator

string

The comparison operator for Critical-level thresholds. 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 value at the same time yesterday.

  • LessThanYesterday: less than the value at the same time yesterday.

  • GreaterThanLastWeek: greater than the value at the same time last week.

  • LessThanLastWeek: less than the value at the same time last week.

  • GreaterThanLastPeriod: greater than the value in the last period.

  • LessThanLastPeriod: less than the value in the last period.

GreaterThanOrEqualToThreshold

PreCondition

string

The precondition for Critical-level alerts. This parameter works together with the ComparisonOperator parameter when ComparisonOperator is set to a year-over-year or period-over-period comparison.

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 more than 10% compared with yesterday.

Note

$Average in $Average>0 is a placeholder in the format of $monitoring result field value. CloudMonitor replaces it with the corresponding statistical value or raw monitoring value.

$Average>80

Times

integer

The number of consecutive occurrences of Critical-level alerts. An alert is triggered only when the threshold is exceeded for this number of consecutive times.

3

Threshold

string

The threshold for Critical-level alerts.

90

Statistics

string

The statistical method for Critical-level alerts.

Average

NoDataPolicy

string

The processing method when no monitoring data is available. Valid values:

  • KEEP_LAST_STATE (default): No action is taken.

  • INSUFFICIENT_DATA: The alert content indicates that no data is available.

  • OK: Normal.

KEEP_LAST_STATE

CompositeExpression

object

The alert conditions for multiple metrics.

Note

Single-metric and multi-metric alert conditions are mutually exclusive and cannot be set at the same time.

Level

string

The alert level. Valid values:

  • CRITICAL: critical.

  • WARN: warning.

  • INFO: information.

CRITICAL

ExpressionList

object

ExpressionList

array<object>

The list of alert conditions created in standard mode.

object

None.

MetricName

string

The metric name of the Alibaba 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:

  • $Maximum: maximum value.

  • $Minimum: minimum value.

  • $Average: average value.

  • $Availability: active rate (typically used for site monitoring).

Note

$ is the unified prefix for metrics. For supported Alibaba Cloud services, see cloud service monitoring metrics.

$Maximum

ComparisonOperator

string

The comparison operator for thresholds. 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 value at the same time yesterday.

  • LessThanYesterday: less than the value at the same time yesterday.

  • GreaterThanLastWeek: greater than the value at the same time last week.

  • LessThanLastWeek: less than the value at the same time last week.

  • GreaterThanLastPeriod: greater than the value in the last period.

  • LessThanLastPeriod: less than the value in the last period.

GreaterThanOrEqualToThreshold

Threshold

string

The alert threshold.

90

ExpressionListJoin

string

The relationship between multi-metric alert conditions. Valid values:

  • &&: An alert is triggered only when all metrics meet the alert conditions. An alert is triggered only when all expressions under ExpressionList evaluate to true.

  • ||: An alert is triggered when any metric meets the alert conditions.

||

ExpressionRaw

string

The alert conditions created by using expressions. The following scenarios are supported but not limited to:

  • Set an alert blacklist for specific resources. For example, $instanceId != 'i-io8kfvcpp7x5****' ``&&`` $Average > 50 indicates that no alert is triggered for instance i-io8kfvcpp7x5**** even when its Average exceeds 50.

  • Set a special alert threshold for a specific instance. For example, $Average > ($instanceId == 'i-io8kfvcpp7x5****'? 80: 50) indicates that an alert is triggered for instance i-io8kfvcpp7x5**** only when its Average exceeds 80, while an alert is triggered for other instances when their Average exceeds 50.

  • Limit the number of instances that exceed the threshold. For example, count($Average > 20) > 3 indicates that an alert is triggered only when more than 3 instances have an Average greater than 20.

$Average > ($instanceId == 'i-io8kfvcpp7x5****'? 80: 50)

Times

integer

The number of times that the alert conditions 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

Set this parameter only when you create a Prometheus alert rule for Hybrid Cloud Monitoring.

PromQL

string

The PromQL query statement.

Note

The data retrieved by the PromQL query statement is the alert data. Include the alert threshold in this statement.

CpuUsage{instanceId="xxxx"}[1m]>90

Level

string

The alert level. Valid values:

  • CRITICAL: critical.

  • WARN: warning.

  • INFO: information.

CRITICAL

Times

integer

The number of times that the alert conditions must be met before an alert notification is sent.

3

Annotations

object

Annotations

array<object>

The annotations for Prometheus alerts. The keys and values of annotations are rendered to help you understand the metrics or alert rules.

Note

This feature is equivalent to the Annotation feature in 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 }} }

SendOK

boolean

是否关闭恢复告警。取值:true(是)、false(否)。

true

ProductCategory

string

The type of the Alibaba 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

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} 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 }} }"
              }
            ]
          }
        },
        "ProductCategory": "slb",
        "GmtCreate": 1760432061000,
        "GmtUpdate": "1760432061000"
      }
    ]
  }
}

Error codes

HTTP status code

Error code

Error message

Description

400 InvalidParameter Invalid parameter. 参数错误
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. 未找到指定资源。

See Error Codes for a complete list.

Release notes

See Release Notes for a complete list.