Creates or modifies an alert rule for an application group.

This topic provides an example on how to create an alert rule for the cpu_total metric of Elastic Compute Service (ECS) in the 17285**** application group. The ID of the alert rule is 123456. The name of the alert rule is Rule_test. The alert level is Critical. The statistical method is Average. The alert threshold comparator is GreaterThanOrEqualToThreshold. The alert threshold is 90. The number of alert retries is 3. The returned result inidcates that the alert rule is created and the alert rule ID is 123456.

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 PutGroupMetricRule

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

GroupId String Yes 17285****

The ID of the application group.

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

RuleId String Yes 123456

The ID of the alert rule.

  • When you create an alert rule for the application group, enter the ID of the alert rule.
  • When you modify a specified alert rule in the application group, you must obtain the ID of the alert rule. For information about how to obtain the ID of an alert rule, see DescribeMetricRuleList.
Category String Yes ECS

The name of the cloud service. Valid values:

  • PolarDB: PolarDB
  • NewBGPDDoS: Anti-DDoS Pro
  • IoTDevice: IoT Platform
  • DRDS: PolarDB-X
  • VS: Video Surveillance System
  • AMQP: Alibaba Cloud Message Queue for AMQP
  • ADS: AnalyticDB
  • APIGateway: API Gateway
  • InternetSharedBandwidth: EIP Bandwidth Plan
  • CDN: Alibaba Cloud Content Delivery Network (CDN)
  • CEN: Cloud Enterprise Network (CEN)
  • DCDN: Dynamic Route for CDN (DCDN)
  • DDoS: Anti-DDoS
  • ECS: Elastic Compute Service (ECS)
  • DirectMail: Direct Mail
  • Elasticsearch: Elasticsearch
  • EMR: E-MapReduce (EMR)
  • ESS: Auto Scaling
  • FunctionCompute: Function Compute
  • RealtimeCompute: Realtime Compute for Apache Flink
  • GlobalAcceleration: Global Accelerator (GA)
  • Hbase: ApsaraDB for HBase
  • TSDB: Time Series Database (TSDB)
  • IPv6trans: IPv6 Translation Service
  • Kafka: Message Queue for Apache Kafka
  • Kubernetes: Container Service for Kubernetes (ACK)
  • KVstore: ApsaraDB for Redis
  • MNS: Message Service (MNS)
  • MongoDB: ApsaraDB for MongoDB
  • MQ: Message Queue
  • NAT: NAT Gateway
  • OpenAd: Open Ad
  • OpenSearch: Open Search
  • OSS: Object Storage Service (OSS)
  • PCDN: P2P CDN
  • petadata: HybridDB for MySQL
  • RDS: ApsaraDB RDS
  • SCDN: Secure CDN
  • SLB: Server Load Balancer (SLB)
  • SLS: Log Service
  • VideoLive: ApsaraVideo Live
  • VOD: ApsaraVideo VOD
  • EIP: Elastic IP Address (EIP)
  • VPN: VPN Gateway
  • AIRec: Artificial Intelligence Recommendation (AIRec)
  • GPDB: AnalyticDB for PostgreSQL
  • DBS: Database Backup (DBS)
  • SAG: Smart Access Gateway (SAG)
  • Memcache: ApsaraDB for Memcache
  • IOT_EDGE: Link IoT Edge
  • OCS: ApsaraDB for Memcache (previous version)
  • VPC: Express Connect
  • EHPC: Elastic High Performance Computing (E-HPC)
  • MPS: ApsaraVideo Media Processing (MPS)
  • ENS: Edge Node Service (ENS)
  • MaxCompute_Prepay: MaxCompute
  • IoT_Kubernetes: Edge Application Hosting
  • CMS: CloudMonitor
  • batchcomputenew: Batch Compute
  • HBaseUE: ApsaraDB for HBase Performance-enhanced Edition
  • UIS: Ultimate Internet Service (UIS)
  • nls: Intelligent Speech Interaction
  • ots: Tablestore
  • NAS: Apsara File Storage NAS
  • ECI: Elastic Container Instance (ECI)
  • OpenAPI: OpenAPI Explorer
  • pvtzpost: Alibaba Cloud DNS PrivateZone
  • blinkonk8s: Flink on Kubernetes
  • FunctionFlow: Serverless Workflow (SWF)
  • SMC: Server Migration Center (SMC)
  • ddosbgp: Anti-DDoS Origin
  • baas: Blockchain as a Service
  • privatelink: PrivateLink
  • cds: ApsaraDB for Cassandra
  • DDH: Dedicated Host
  • RocketMQ: Message Queue for Apache RocketMQ
  • ECC: Express Cloud Connect (ECC)
  • hbaseserverless: ApsaraDB for HBase Serverless Edition
  • mns_tmp: Message Service
  • hdr: Hybrid Disaster Recovery (HDR)
  • hbr: Hybrid Backup Recovery (HBR)
  • ADB: AnalyticDB for MySQL V3.0
  • tag: Tag Service
  • GDB: Graph Database
  • WAF: Web Application Firewall (WAF)
  • hcs_sgw: Cloud Storage Gateway (CSG)
  • ipv6gateway: IPv6 Gateway
  • RDS_SAR: ApsaraDB Exclusive Host Group
  • learn: Machine Learning Platform for AI
  • ROS: Resource Orchestration Service (ROS)
  • OOS: Operation Orchestration Service (OOS)
  • bds: Data Synchronization for HBase
  • cfw: Cloud Firewall
  • ddosDip: Anti-DDoS Premium
  • datahub: DataHub
  • hologres: Hologres
  • ExpressConnect: Express Connect
  • dbfs: Database File System (DBFS)
  • clickhouse: ApsaraDB for ClickHouse
  • k8s: Container Service for Kubernetes (ACK)
  • DTS: Data Transmission Service (DTS)
  • AnycastEIP: Anycast Elastic IP Address
  • Lindorm: ApsaraDB for Lindorm
  • config: Cloud Config
  • spark: Databricks DataInsight (DDI)
  • serverless: Serverless App Engine (SAE)
  • alb: Application Load Balancer (ALB)
  • oceanbase: ApsaraDB for OceanBase
  • KMS: Key Management Service (KMS)
  • lvwang: Content Moderation
  • LinkVisual: LinkVisual
  • tair: ApsaraDB for Redis Enhanced Edition (Tair)
  • dlf: Data Lake Formation (DLF)
  • networkmonitor: Site Monitoring
  • pnc: Physical Network Change
  • AIS: Alibaba Cloud Infrastructure
  • cloudgame: Cloud Gaming Platform
  • RTC: Real-Time Communication
  • cloudbox: CloudBox
  • actiontrail: ActionTrail
  • cc: Cloud Connector
  • disk: Elastic Block Storage (EBS)
  • easygene: Genomics Computing Platform
  • cloudphone: Elastic Cloud Phone
  • BMS: Bare Metal Management Service
  • swas: Simple Application Server
  • AvailabilityMonitoring: Availability Monitoring of CloudMonitor
RuleName String Yes Rule_01

The name of the alert rule.

  • When you create an alert rule for the application group, enter the name of the alert rule.
  • When you modify a specified alert rule in the application group, you must obtain the name of the alert rule. For information about how to obtain the name of an alert rule, see DescribeMetricRuleList.
Namespace String Yes 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.

MetricName String Yes cpu_total

The name of the metric.

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

Dimensions String No [{"instanceId":"i-m5e1qg6uo38rztr4****"}]

The first-level dimension of the alert rule in the application group.

Set the value to a set of key-value pairs, for example, userId:120886317861**** or instanceId:i-m5e1qg6uo38rztr4****.

ExtraDimensionJson String No {"/dev/xvda":"d-m5e6yphgzn3aprwu****"}

The second-level or third-level dimension of the alert rule in the application group.

Set the value to a set of key-value pairs, for example, port:80 or /dev/xvda:d-m5e6yphgzn3aprwu****.

If the first-level dimension of the alert rule is instanceId:i-m5e1qg6uo38rztr4****, its second-level dimension is the /dev/xvda:d-m5e6yphgzn3aprwu**** disk in the instance.

EffectiveInterval String No 05:31-23:59

The time period during which the alert rule is effective.

NoEffectiveInterval String No 00:00-05:30

The time period during which the alert rule is ineffective.

SilenceTime Integer No 86400

The mute period during which new alerts are not sent even if the trigger conditions are met.

Unit: seconds. Default value: 86400.

Period String No 60

The aggregation period of the metric data.

Set the Period parameter to an integral multiple of 60. Unit: seconds. Default value: 300.

Interval String No 60

The interval at which the alert rule is executed. Unit: seconds.

Note We recommend that you set the interval to the data aggregation period. If the interval is shorter than the data aggregation period, alerts cannot be triggered due to insufficient data.
Webhook String No https://www.aliyun.com

The callback URL.

The callback URL must be accessible over the Internet. CloudMonitor sends a POST request to push an alert notification to the callback URL that you specify. Only HTTP requests are supported.

EmailSubject String No ECS instance

The subject of the alert notification email.

ContactGroups String No ECS_Group

The alert contact group.

Escalations.Critical.Statistics String No Average

The statistical methods for Critical-level alerts. Separate multiple statistical methods with commas (,). Valid values:

  • Average: the average value
  • Minimum: the minimum value
  • Maximum: the maximum value
Escalations.Critical.ComparisonOperator String No 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
Escalations.Critical.Threshold String No 90

The threshold for Critical-level alerts.

Escalations.Critical.Times Integer No 3

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

Escalations.Warn.Statistics String No Average

The statistical methods for Warn-level alerts. Separate multiple statistical methods with commas (,). Valid values:

  • Average: the average value
  • Minimum: the minimum value
  • Maximum: the maximum value
Escalations.Warn.ComparisonOperator String No 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
Escalations.Warn.Threshold String No 90

The threshold for Warn-level alerts.

Escalations.Warn.Times Integer No 3

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

Escalations.Info.Statistics String No Average

The statistical methods for Info-level alerts. Separate multiple statistical methods with commas (,). Valid values:

  • Average: the average value
  • Minimum: the minimum value
  • Maximum: the maximum value
Escalations.Info.ComparisonOperator String No 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
Escalations.Info.Threshold String No 90

The threshold for Info-level alerts.

Escalations.Info.Times Integer No 3

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

NoDataPolicy String No KEEP_LAST_STATE

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.
Labels.N.Key String No key1

The tag key of the alert rule.

Labels.N.Value String No value1

The tag value of the alert rule.

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

Response parameters

Parameter Type Example Description
Code String 200

The HTTP status code.

Note The status code 200 indicates that the call was successful.
Message String The Request is not authorization.

The error message.

RequestId String 461CF2CD-2FC3-4B26-8645-7BD27E7D0F1D

The ID of the request.

Success Boolean true

Indicates whether the call was successful. Valid values:

  • true: The call was successful.
  • false: The call failed.
Result Object

The result of the request.

RuleId String 123456

The ID of the alert rule.

Examples

Sample requests

http(s)://[Endpoint]/?Action=PutGroupMetricRule
&Category=ECS
&GroupId=17285****
&MetricName=cpu_total
&Namespace=acs_ecs_dashboard
&RuleId=123456
&RuleName=`Rule_test
&Escalations.Critical.Statistics=Average
&Escalations.Critical.ComparisonOperator=GreaterThanOrEqualToThreshold
&Escalations.Critical.Threshold=90
&Escalations.Critical.Times=3
&<Common request parameters>

Sample success responses

XML format

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

<PutGroupMetricRuleResponse>
	<Message></Message>
	<RequestId>461CF2CD-2FC3-4B26-8645-7BD27E7D0F1D</RequestId>
	<Code>200</Code>
	<Success>true</Success>
	<Result>
		<RuleId>123456</RuleId>
	</Result>
</PutGroupMetricRuleResponse>

JSON format

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

{
  "Message" : "",
  "RequestId" : "461CF2CD-2FC3-4B26-8645-7BD27E7D0F1D",
  "Code" : 200,
  "Success" : true,
  "Result" : {
    "RuleId" : "123456"
  }
}

Error codes

For a list of error codes, visit the API Error Center.