All Products
Search
Document Center

CloudMonitor:CreateGroupMetricRules

Last Updated:Oct 31, 2024

Creates one or more alert rules for a specified application group.

Operation description

This topic provides an example to show how to create an alert rule for the cpu_total metric of Elastic Compute Service (ECS) in the 123456 application group. The ID of the alert rule is 456789. The name of the alert rule is ECS_Rule1. The alert level is Critical. The statistical method is Average. The comparison operator is GreaterThanOrEqualToThreshold. The alert threshold is 90. The number of alert retries is 3. The response shows that the alert rule named ECS_Rule1 is created.

Debugging

You can run this interface directly in OpenAPI Explorer, saving you the trouble of calculating signatures. After running successfully, OpenAPI Explorer can automatically generate SDK code samples.

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:CreateGroupMetricRulescreate
  • GroupMetricRule
    acs:cms::{#accountId}:group/{#groupId}
    none
none

Request parameters

ParameterTypeRequiredDescriptionExample
GroupIdlongYes

The ID of the application group.

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

123456
GroupMetricRulesarray<object>No
objectNo

The statistical methods for Warn-level alerts. Separate multiple statistical methods with commas (,). Valid values of N: 1 to 200. Valid value:

  • Average: the average value
  • Minimum: the minimum value
  • Maximum: the maximum value
Escalations.Info.ThresholdstringNo

The threshold for Info-level alerts. Valid values of N: 1 to 200.

10
MetricNamestringYes

The name of the metric. Valid values of N: 1 to 200.

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

cpu_total
Escalations.Warn.ThresholdstringNo

The threshold for Warn-level alerts. Valid values of N: 1 to 200.

20
EffectiveIntervalstringNo

The time period during which the alert rule is effective. Valid values of N: 1 to 200.

05:31-23:59
NoEffectiveIntervalstringNo

The time period during which the alert rule is ineffective. Valid values of N: 1 to 200.

00:00-05:30
RuleIdstringYes

The ID of the alert rule. Valid values of N: 1 to 200.

456789
Escalations.Critical.TimesintegerNo

The consecutive number of times for which the metric value meets the alert condition before a Critical-level alert is triggered. Valid values of N: 1 to 200.

3
DimensionsstringNo

The dimension of the alert rule. Valid values of N: 1 to 200.

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

[{"instanceId":"i-m5e1qg6uo38rztr4****"}]
Escalations.Critical.ThresholdstringNo

The threshold for Critical-level alerts. Valid values of N: 1 to 200.

90
Escalations.Critical.StatisticsstringNo

The statistical methods for Critical-level alerts. Separate multiple statistical methods with commas (,). Valid values of N: 1 to 200. Valid value:

  • Average: the average value
  • Minimum: the minimum value
  • Maximum: the maximum value
Average
Escalations.Warn.ComparisonOperatorstringNo

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

  • 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
Escalations.Info.TimesintegerNo

The consecutive number of times for which the metric value meets the alert condition before an Info-level alert is triggered. Valid values of N: 1 to 200.

1
SilenceTimeintegerNo

The mute period during which new alerts are not sent even if the trigger conditions are met. Valid values of N: 1 to 200.

Unit: seconds. Default value: 86400. Minimum value: 3600.

86400
WebhookstringNo

The callback URL. Valid values of N: 1 to 200.

The callback URL must be accessible over the Internet. 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
NamespacestringYes

The namespace of the cloud service. Valid values of N: 1 to 200.

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

acs_ecs_dashboard
EmailSubjectstringNo

The subject of the alert notification email. Valid values of N: 1 to 200.

PeriodstringNo

The aggregation period of the metric data. Valid values of N: 1 to 200.

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

60
RuleNamestringYes

The name of the alert rule. Valid values of N: 1 to 200.

ECS_Rule1
Escalations.Info.StatisticsstringNo

The statistical methods for Info-level alerts. Separate multiple statistical methods with commas (,). Valid values of N: 1 to 200. Valid value:

  • Average: the average value
  • Minimum: the minimum value
  • Maximum: the maximum value
Average
Escalations.Warn.TimesintegerNo

The consecutive number of times for which the metric value meets the alert condition before a Warn-level alert is triggered. Valid values of N: 1 to 200.

3
Escalations.Info.ComparisonOperatorstringNo

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

  • 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
IntervalstringNo

The interval at which CloudMonitor checks whether the alert rule is triggered. Valid values of N: 1 to 200.

Unit: seconds. The default value is the lowest frequency at which the metric is polled.

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.
60
CategorystringYes

The name of the cloud service. Valid values of N: 1 to 200. Valid value:

  • PolarDB: PolarDB
  • NewBGPDDoS: Anti-DDoS Pro
  • IoTDevice: IoT Platform
  • DRDS: Distributed Relational Database Service (DRDS)
  • 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
  • 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
  • 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: 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
  • 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
ECS
Escalations.Critical.ComparisonOperatorstringNo

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

  • 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
Escalations.Warn.StatisticsstringNo

The statistical methods for Warn-level alerts. Separate multiple statistical methods with commas (,). Valid values of N: 1 to 200. Valid value:

  • Average: the average value
  • Minimum: the minimum value
  • Maximum: the maximum value
Average
NoDataPolicystringNo

The method that is used to handle alerts when no monitoring data is found. Valid values of N: 1 to 200. Valid value:

  • KEEP_LAST_STATE (default value): No operation is performed.
  • INSUFFICIENT_DATA: An alert whose content is "Insufficient data" is triggered.
  • OK: The alert rule has no active alerts.
KEEP_LAST_STATE
ContactGroupsstringNo

The alert contact groups. Valid values of N: 1 to 200.

For information about how to obtain alert contact groups, see DescribeContactGroupList .

ECS_Group
Labelsarray<object>No
objectNo
KeystringNo

The tag key of the alert rule. The specified tag is contained in alert notifications.

Valid values of N: 1 to 200.

key1
ValuestringNo

The tag value of the alert rule. The specified tag is contained in alert notifications.

Valid values of N: 1 to 200.

value1

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

Response parameters

ParameterTypeDescriptionExample
object
Codeinteger

The HTTP status code.

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

The error message.

The Request is not authorization.
RequestIdstring

The ID of the request.

461CF2CD-2FC3-4B26-8645-7BD27E7D0F1D
Successboolean

Indicates whether the call is successful. Valid value:

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

The details of the alert rules.

AlertResultobject
Codeinteger

The status code that is returned for the alert rule.

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

The error message that is returned for the alert rule.

Metric not found.
Successboolean

Indicates whether the alert rule was created. Valid value:

  • true: The alert rule was created.
  • false: The alert rule failed to be created.
true
RuleNamestring

The name of the alert rule.

ECS_Rule1
RuleIdstring

The ID of the alert rule.

456789

Examples

Sample success responses

JSONformat

{
  "Code": 200,
  "Message": "The Request is not authorization.",
  "RequestId": "461CF2CD-2FC3-4B26-8645-7BD27E7D0F1D",
  "Success": true,
  "Resources": {
    "AlertResult": [
      {
        "Code": 200,
        "Message": "Metric not found.",
        "Success": true,
        "RuleName": "ECS_Rule1",
        "RuleId": "456789"
      }
    ]
  }
}

Error codes

HTTP status codeError codeError message
400%s%s
500500%s

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

Change history

Change timeSummary of changesOperation
2023-12-13The Error code has changedView Change Details
2021-10-28The Error code has changedView Change Details
2021-10-28The Error code has changedView Change Details