CreateMetricRuleTemplate

Updated at:

Creates an alert template.

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:CreateMetricRuleTemplate

create

*All Resource

*

None None

Request parameters

Parameter

Type

Required

Description

Example

Name

string

Yes

The name of the alert template.

Template1

Description

string

No

The description of the alert template.

ECS_Template1

AlertTemplates

array<object>

No

The alert templates.

object

No

The alert template.

Escalations.Info.Threshold

string

No

The threshold for info-level alerts.

Valid values of N: 1 to 200.

Note

You must specify at least one of the following alert levels: Critical, Warn, or Info. For the specified alert level, you must specify the Statistics, ComparisonOperator, Threshold, and Times parameters at the same time.

20

MetricName

string

Yes

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

Note

For more information, see DescribeMetricMetaList or Cloud service metrics.

cpu_total

Webhook

string

No

The webhook URL to which a POST request is sent when an alert is triggered.

http://ww.aliyun.com

Escalations.Warn.Threshold

string

No

The threshold for warn-level alerts.

Valid values of N: 1 to 200.

Note

You must specify at least one of the following alert levels: Critical, Warn, or Info. For the specified alert level, you must specify the Statistics, ComparisonOperator, Threshold, and Times parameters at the same time.

30

Namespace

string

Yes

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

Note

For more information, see DescribeMetricMetaList or Cloud service metrics.

acs_ecs_dashboard

Period

integer

No

The aggregation period of the monitoring data. Unit: seconds.

Default value: the minimum aggregation period of the metric. You do not need to specify this parameter in most cases.

Valid values of N: 1 to 200.

60

RuleName

string

Yes

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

My CPU monitoring

Escalations.Critical.Times

integer

No

The number of consecutive times the monitoring metrics must reach the alert threshold to send a critical-level alert notification.

Valid values of N: 1 to 200.

Note

You must specify at least one of the following alert levels: Critical, Warn, or Info. For the specified alert level, you must specify the Statistics, ComparisonOperator, Threshold, and Times parameters at the same time.

3

Selector

string

No

The options for extended fields. Valid values of N: 1 to 200.

{"disk":"/"}

Escalations.Info.Statistics

string

No

The statistical method for info-level alerts.

Valid values of N: 1 to 200.

The valid values of this parameter are determined by the Statistics column that corresponds to the MetricName of the specified cloud service. Examples: Maximum, Minimum, and Average. For more information about how to obtain the valid values, see Cloud service monitoring metrics.

Note

You must specify at least one of the following alert levels: Critical, Warn, or Info. For the specified alert level, you must specify the Statistics, ComparisonOperator, Threshold, and Times parameters at the same time.

Average

Escalations.Warn.Times

integer

No

The number of consecutive times the monitoring metrics must reach the alert threshold to send a warning alert notification.

Valid values of N: 1 to 200.

Note

You must specify at least one of the following alert levels: Critical, Warn, or Info. For the specified alert level, you must specify the Statistics, ComparisonOperator, Threshold, and Times parameters at the same time.

1

Escalations.Info.ComparisonOperator

string

No

The comparison operator for the info-level threshold. Valid values:

  • GreaterThanOrEqualToThreshold: greater than or equal to

  • GreaterThanThreshold: greater than

  • LessThanOrEqualToThreshold: less than or equal to

  • LessThanThreshold: less than

  • NotEqualToThreshold: not equal to

  • 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

Valid values of N: 1 to 200.

Note

You must specify at least one of the following alert levels: Critical, Warn, or Info. For the specified alert level, you must specify the Statistics, ComparisonOperator, Threshold, and Times parameters at the same time.

GreaterThanOrEqualToThreshold

Category

string

Yes

The Alibaba Cloud service name or product specification abbreviation. Valid values of N: 1 to 200. Valid values:

  • ecs: ECS instances and non-Alibaba Cloud hosts

  • rds: ApsaraDB RDS database

  • ads: AnalyticDB database

  • slb: load balancing

  • vpc: Elastic IP

  • apigateway: API Gateway

  • cdn: Content Delivery Network

  • cs: Container Service for Swarm

  • dcdn: Dynamic Route for CDN

  • ddos: Anti-DDoS

  • eip: Elastic IP Address

  • elasticsearch: Elasticsearch

  • emr: E-MapReduce

  • ess: elastic scaling

  • hbase: ApsaraDB for HBase database

  • iot_edge: IoT Edge

  • k8s_pod: Kubernetes pod

  • kvstore_sharding: ApsaraDB for Redis Cluster Edition

  • kvstore_splitrw: ApsaraDB for Redis Read/Write Splitting Edition

  • kvstore_standard: ApsaraDB for Redis Standard Edition

  • memcache: ApsaraDB for Memcache database

  • mns: Message Service

  • mongodb: MongoDB replica set

  • mongodb_cluster: MongoDB cluster edition

  • mongodb_sharding: MongoDB sharded cluster

  • mq_topic: Message Service topic

  • ocs: legacy ApsaraDB for Memcache database

  • opensearch: OpenSearch

  • oss: Object Storage Service

  • polardb: PolarDB database

  • petadata: HybridDB for MySQL

  • scdn: secure acceleration

  • sharebandwidthpackages: Internet Shared Bandwidth

  • sls: Simple Log Service

  • vpn: VPN Gateway

ecs

Escalations.Critical.Threshold

string

No

The threshold that triggers a critical-level alert notification.

Valid values of N: 1 to 200.

Note

You must specify at least one of the following alert levels: Critical, Warn, or Info. For the specified alert level, you must specify the Statistics, ComparisonOperator, Threshold, and Times parameters at the same time.

30

Escalations.Critical.Statistics

string

No

The statistical method for critical-level alerts.

Valid values of N: 1 to 200.

The valid values of this parameter are determined by the Statistics column that corresponds to the MetricName of the specified cloud service. Examples: Maximum, Minimum, and Average. For more information about how to obtain the valid values, see Cloud service monitoring metrics.

Note

You must specify at least one of the following alert levels: Critical, Warn, or Info. For the specified alert level, you must specify the Statistics, ComparisonOperator, Threshold, and Times parameters at the same time.

Average

Escalations.Critical.ComparisonOperator

string

No

The comparison operator for the critical-level threshold. Valid values:

  • GreaterThanOrEqualToThreshold: greater than or equal to

  • GreaterThanThreshold: greater than

  • LessThanOrEqualToThreshold: less than or equal to

  • LessThanThreshold: less than

  • NotEqualToThreshold: not equal to

  • 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

Valid values of N: 1 to 200.

Note

You must specify at least one of the following alert levels: Critical, Warn, or Info. For the specified alert level, you must specify the Statistics, ComparisonOperator, Threshold, and Times parameters at the same time.

GreaterThanOrEqualToThreshold

Escalations.Warn.ComparisonOperator

string

No

The comparison operator for the warn-level threshold. Valid values:

  • GreaterThanOrEqualToThreshold: greater than or equal to

  • GreaterThanThreshold: greater than

  • LessThanOrEqualToThreshold: less than or equal to

  • LessThanThreshold: less than

  • NotEqualToThreshold: not equal to

  • 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

Valid values of N: 1 to 200.

Note

You must specify at least one of the following alert levels: Critical, Warn, or Info. For the specified alert level, you must specify the Statistics, ComparisonOperator, Threshold, and Times parameters at the same time.

GreaterThanOrEqualToThreshold

Escalations.Info.Times

integer

No

The number of consecutive times the monitoring metrics must reach the alert threshold to send an info-level alert notification.

Valid values of N: 1 to 200.

Note

You must specify at least one of the following alert levels: Critical, Warn, or Info. For the specified alert level, you must specify the Statistics, ComparisonOperator, Threshold, and Times parameters at the same time.

1

Escalations.Warn.Statistics

string

No

The statistical method for warning alerts.

Valid values of N: 1 to 200.

The valid values of this parameter are determined by the Statistics column that corresponds to the MetricName of the specified cloud service. Examples: Maximum, Minimum, and Average. For more information about how to obtain the valid values, see Cloud service monitoring metrics.

Note

You must specify at least one of the following alert levels: Critical, Warn, or Info. For the specified alert level, you must specify the Statistics, ComparisonOperator, Threshold, and Times parameters at the same time.

Average

Response elements

Element

Type

Description

Example

object

The response data.

Code

integer

The HTTP status code.

Note

A status code of 200 indicates that the request was successful.

200

Message

string

The error message.

The Request is not authorization.

RequestId

string

The request ID.

9763ED1A-4D09-41BF-851E-310421750204

Success

boolean

Indicates whether the operation was successful. Valid values:

  • true: The operation was successful.

  • false: The operation failed.

true

Id

integer

The ID of the alert template.

12345

Examples

Success response

JSON format

{
  "Code": 200,
  "Message": "The Request is not authorization.",
  "RequestId": "9763ED1A-4D09-41BF-851E-310421750204",
  "Success": true,
  "Id": 12345
}

Error codes

HTTP status code

Error code

Error message

Description

400 InvalidQueryParameter %s
401 AccessDeniedException You donot have sufficient access to perform this action.
412 ResourcesOverLimit Resources over limit.
500 InternalFailure %s
402 LimitExceeded The quota for this customer had been reached.
403 InvalidClientTokenId not allow this operation. No permission
206 %s %s
503 %s %s
406 %s %s
429 Throttli∂ngException The request was denied due to request throttling.
409 %s %s
409 ResourceConflict Concurrent modification of resources.
409 ResourceExist Resources already exist.

See Error Codes for a complete list.

Release notes

See Release Notes for a complete list.