Queries alert rules.

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. OpenAPI Explorer dynamically generates the sample code of the operation for different SDKs.

Request parameters

Parameter Type Required Example Description
Action String Yes DescribeMetricRuleList

The operation that you want to perform. Set the value to DescribeMetricRuleList.

MetricName String No cpu_total

The name of the metric.

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

EnableState Boolean No true

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

  • true: queries enabled alert rules.
  • false: queries disabled alert rules.
Namespace String No acs_ecs_dashboard

The namespace of the cloud service.

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

Page Integer No 1

The page number.

Pages start from page 1. Default value: 1.

PageSize Integer No 10

The number of entries per page.

Pages start from page 1. Default value: 10.

AlertState String No OK

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.
Dimensions String No {"instanceId":"i-2ze2d6j5uhg20x47****"}

The monitoring dimensions of the specified resource.

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

RuleName String No Rule_01

The name of the alert rule.

This parameter supports fuzzy match.

GroupId String No 7301****

The ID of the application group.

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

RuleIds String No applyTemplate344cfd42-0f32-4fd6-805a-88d7908a****

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

For more information about common request parameters, see Common parameters.

Response parameters

Parameter Type Example Description
Code Integer 200

The HTTP status code.

Note The status code 200 indicates that the request was successful.
Message String The specified resource is not found.

The error message.

RequestId String 386C6712-335F-5054-930A-CC92B851ECBA

The request ID.

Total String 1

The total number of entries.

Success Boolean true

Indicates whether the request was successful. Valid values:

  • true
  • false
Alarms Array of Alarm

The details of the alert rules.

Alarm
SilenceTime Integer 86400

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 threshold several times.

MetricName String cpu_total

The name of the metric.

Webhook String https://www.aliyun.com

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.

ContactGroups String ECS_Alarm

The alert contact groups.

SourceType String METRIC

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

Namespace String acs_ecs_dashboard

The namespace of the cloud service.

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

The subject of the alert notification email.

NoEffectiveInterval String 00:00-05:30

The time period during which the alert rule is ineffective.

EffectiveInterval String 05:31-23:59

The time period during which the alert rule is effective.

RuleName String Rule_01

The name of the alert rule.

AlertState String OK

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.
Period String 60

The statistical period.

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

The ID of the alert rule.

GroupName String ECS_Group

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.
GroupId String 7301****

The ID of the application group.

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

The dimensions of the alert rule.

EnableState Boolean true

Indicates whether the alert rule is enabled. Valid values:

  • true: The alert rule is enabled.
  • false: The alert rule is disabled.
Resources String [{\"instanceId\":\"i-2ze2d6j5uhg20x47****\"}]

The resources that are associated with the alert rule.

Escalations Object

The conditions for triggering different levels of alerts.

Info Object

The conditions for triggering Info-level alerts.

ComparisonOperator String GreaterThanOrEqualToThreshold

The comparison operator that is used to compare the metric value with the threshold for Info-level alerts. 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
PreCondition String $Average>80

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.
Times Integer 3

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

Threshold String 90

The threshold for Info-level alerts.

Statistics String Average

The statistical methods for Info-level alerts.

Warn Object

The conditions for triggering Warn-level alerts.

ComparisonOperator String GreaterThanOrEqualToThreshold

The comparison operator that is used to compare the metric value with the threshold for Warn-level alerts. 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
PreCondition String $Average>80

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.
Times Integer 3

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

Threshold String 90

The threshold for Warn-level alerts.

Statistics String Average

The statistical methods for Warn-level alerts.

Critical Object

The conditions for triggering Critical-level alerts.

ComparisonOperator String GreaterThanOrEqualToThreshold

The comparison operator that is used to compare the metric value with the threshold for Critical-level alerts. 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
PreCondition String $Average>80

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.
Times Integer 3

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

Threshold String 90

The threshold for Critical-level alerts.

Statistics String Average

The statistical methods for Critical-level alerts.

NoDataPolicy String KEEP_LAST_STATE

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

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

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.
Level String Critical

The alert level. Valid values:

  • Critical
  • Warn
  • Info
ExpressionList Array of ExpressionList

The trigger conditions that are created in standard mode.

ExpressionList
MetricName String cpu_total

The metric that is used to monitor the cloud service.

ComparisonOperator String GreaterThanOrEqualToThreshold

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
Statistics String $Maximum

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.
Threshold String 90

The alert threshold.

Period Integer 60

The aggregation period of the metric.

Unit: seconds.

ExpressionListJoin String ||

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.
ExpressionRaw String $Average > ($instanceId == 'i-io8kfvcpp7x5****'? 80: 50)

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 generated even 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.
Times Integer 3

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.

Labels Array of Labels

The tags of the alert rule.

Labels
Key String cmsRuleKey

The tag key of the alert rule.

Value String cmsRuleValue

The tag value of the alert rule.

Prometheus Object

The Prometheus alert rule.

Note This parameter is required only when you create a Prometheus alert rule for Hybrid Cloud Monitoring.
PromQL String CpuUsage{instanceId="xxxx"}[1m]>90

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.
Level String Critical

The alert level. Valid values:

  • Critical
  • Warn
  • Info
Times Long 3

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.

Annotations Array of Annotations

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.
Annotations
Key String summary

The key of the annotation.

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

The value of the annotation.

Examples

Sample requests

http(s)://[Endpoint]/?Action=DescribeMetricRuleList
&<Common request parameters>

Sample success responses

XML format

HTTP/1.1 200 OK
Content-Type:application/xml

<DescribeMetricRuleListResponse>
	<RequestId>386C6712-335F-5054-930A-CC92B851ECBA</RequestId>
	<Total>1</Total>
	<Alarms>
		<Alarm>
			<GroupName>ECS_Group</GroupName>
			<SilenceTime>86400</SilenceTime>
			<ContactGroups>ECS_Alarm</ContactGroups>
			<NoEffectiveInterval>00:00-05:30</NoEffectiveInterval>
			<GroupBy>group</GroupBy>
			<MailSubject>${serviceType}-${metricName}-${levelDescription}Notification(${dimensions})</MailSubject>
			<SourceType>METRIC</SourceType>
			<RuleId>applyTemplate344cfd42-0f32-4fd6-805a-88d7908a****</RuleId>
			<Period>60</Period>
			<Dimensions>
				<instanceId>i-2ze2d6j5uhg20x47****</instanceId>
			</Dimensions>
			<EffectiveInterval>05:31-23:59</EffectiveInterval>
			<Namespace>acs_ecs_dashboard</Namespace>
			<AlertState>OK</AlertState>
			<GroupId>7301****</GroupId>
			<MetricName>cpu_total</MetricName>
			<EnableState>true</EnableState>
			<Escalations>
				<Critical>
					<ComparisonOperator>GreaterThanOrEqualToThreshold</ComparisonOperator>
					<Times>3</Times>
					<Statistics>Average</Statistics>
					<Threshold>90</Threshold>
				</Critical>
				<Info>
					<ComparisonOperator>GreaterThanOrEqualToThreshold</ComparisonOperator>
					<Times>3</Times>
					<Statistics>Average</Statistics>
					<Threshold>90</Threshold>
				</Info>
				<Warn>
					<ComparisonOperator>GreaterThanOrEqualToThreshold</ComparisonOperator>
					<Times>3</Times>
					<Statistics>Average</Statistics>
					<Threshold>90</Threshold>
				</Warn>
			</Escalations>
			<Webhook>https://www.aliyun.com</Webhook>
			<Resources>[{\"instanceId\":\"i-2ze2d6j5uhg20x47****\"}]</Resources>
			<RuleName>Rule_01</RuleName>
		</Alarm>
	</Alarms>
	<Code>200</Code>
	<Success>true</Success>
</DescribeMetricRuleListResponse>

JSON format

HTTP/1.1 200 OK
Content-Type:application/json

{
  "RequestId" : "386C6712-335F-5054-930A-CC92B851ECBA",
  "Total" : 1,
  "Alarms" : {
    "Alarm" : [ {
      "GroupName" : "ECS_Group",
      "SilenceTime" : 86400,
      "ContactGroups" : "ECS_Alarm",
      "NoEffectiveInterval" : "00:00-05:30",
      "GroupBy" : "group",
      "MailSubject": "${serviceType}-${metricName}-${levelDescription}Notification(${dimensions})",
      "SourceType" : "METRIC",
      "RuleId" : "applyTemplate344cfd42-0f32-4fd6-805a-88d7908a****",
      "Period" : 60,
      "Dimensions" : [ {
        "instanceId" : "i-2ze2d6j5uhg20x47****"
      } ],
      "EffectiveInterval" : "05:31-23:59",
      "Namespace" : "acs_ecs_dashboard",
      "AlertState" : "OK",
      "GroupId" : "7301****",
      "MetricName" : "cpu_total",
      "EnableState" : true,
      "Escalations" : {
        "Critical" : {
          "ComparisonOperator" : "GreaterThanOrEqualToThreshold",
          "Times" : 3,
          "Statistics" : "Average",
          "Threshold" : "90"
        },
        "Info" : {
          "ComparisonOperator" : "GreaterThanOrEqualToThreshold",
          "Times" : 3,
          "Statistics" : "Average",
          "Threshold" : "90"
        },
        "Warn" : {
          "ComparisonOperator" : "GreaterThanOrEqualToThreshold",
          "Times" : 3,
          "Statistics" : "Average",
          "Threshold" : "90"
        }
      },
      "Webhook" : "https://www.aliyun.com",
      "Resources" : "[{\"instanceId\":\"i-2ze2d6j5uhg20x47****\"}]",
      "RuleName" : "Rule_01"
    } ]
  },
  "Code" : "200",
  "Success" : true
}

Error codes

HTTP status code Error code Error message Description
404 ResourceNotFound The specified resource is not found. The specified resource is not found.

For a list of error codes, see Service error codes.