All Products
Search
Document Center

CloudMonitor:CreateMetricRuleTemplate

Last Updated:Mar 25, 2025

Creates an alert template.

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:
    • For mandatory resource types, indicate with a prefix of * .
    • 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:CreateMetricRuleTemplatecreate
*All Resources
*
    none
none

Request parameters

ParameterTypeRequiredDescriptionExample
NamestringYes

The name of the alert template.

Template1
DescriptionstringNo

The description of the alert template.

ECS_Template1
AlertTemplatesarray<object>No

The details of the alert template.

objectNo

The alert template.

Escalations.Info.ThresholdstringNo

The threshold for Info-level alerts.

Valid values of N: 1 to 200.

Note You must select at least one of the Critical, Warn, and Info alert levels and specify the Statistics, ComparisonOperator, Threshold, and Times parameters for each alert level.
20
MetricNamestringYes

The metric name.

Valid values of N: 1 to 200.

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

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

http://ww.aliyun.com
Escalations.Warn.ThresholdstringNo

The threshold for Warn-level alerts.

Valid values of N: 1 to 200.

Note You must select at least one of the Critical, Warn, and Info alert levels and specify the Statistics, ComparisonOperator, Threshold, and Times parameters for each alert level.
30
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
PeriodintegerNo

The aggregation period of monitoring data. Unit: seconds.

The default value is the minimum aggregation period. Generally, you do not need to specify the minimum aggregation period.

Valid values of N: 1 to 200.

60
RuleNamestringYes

The name of the alert rule.

Valid values of N: 1 to 200.

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

Note You must select at least one of the Critical, Warn, and Info alert levels and specify the Statistics, ComparisonOperator, Threshold, and Times parameters for each alert level.
2
SelectorstringNo

The dimension of the alert. It is an extended field.

Valid values of N: 1 to 200.

For example, an alert template is applied to an application group, this parameter is set to {"disk":"/"}, and the MetricName parameter is set to DiskUtilization. In this case, the generated alert rule is applied to the root disk partition ("/") of all instances in the application group to which the alert template is applied.

Note For more information about the values of extended fields, see DescribeMetricRuleTemplateAttribute .
{"disk":"/"}
Escalations.Info.StatisticsstringNo

The statistical method for Info-level alerts.

Valid values of N: 1 to 200.

The value of this parameter is determined by the Statistics column corresponding to the MetricName parameter of the specified cloud service. The value of this parameter can be Maximum, Minimum, or Average. For more information about how to obtain the value of this parameter, see Appendix 1: Metrics.

Note You must select at least one of the Critical, Warn, and Info alert levels and specify the Statistics, ComparisonOperator, Threshold, and Times parameters for each alert level.
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.

Note You must select at least one of the Critical, Warn, and Info alert levels and specify the Statistics, ComparisonOperator, Threshold, and Times parameters for each alert level.
1
Escalations.Info.ComparisonOperatorstringNo

The 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 previous monitoring cycle

Valid values of N: 1 to 200.

Note You must select at least one of the Critical, Warn, and Info alert levels and specify the Statistics, ComparisonOperator, Threshold, and Times parameters for each alert level.
GreaterThanOrEqualToThreshold
CategorystringYes

The abbreviation of the cloud service name.

Valid values of N: 1 to 200.

For more information about how to obtain the abbreviation of a cloud service name, see metricCategory in the response parameter Labels of the DescribeProjectMeta operation.

ecs
Escalations.Critical.ThresholdstringNo

The threshold for Critical-level alerts.

Valid values of N: 1 to 200.

Note You must select at least one of the Critical, Warn, and Info alert levels and specify the Statistics, ComparisonOperator, Threshold, and Times parameters for each alert level.
30
Escalations.Critical.StatisticsstringNo

The statistical method for Critical-level alerts.

Valid values of N: 1 to 200.

The value of this parameter is determined by the Statistics column corresponding to the MetricName parameter of the specified cloud service. The value of this parameter can be Maximum, Minimum, or Average. For more information about how to obtain the value of this parameter, see Appendix 1: Metrics.

Note You must select at least one of the Critical, Warn, and Info alert levels and specify the Statistics, ComparisonOperator, Threshold, and Times parameters for each alert level.
Average
Escalations.Critical.ComparisonOperatorstringNo

The 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 previous monitoring cycle

Valid values of N: 1 to 200.

Note You must select at least one of the Critical, Warn, and Info alert levels and specify the Statistics, ComparisonOperator, Threshold, and Times parameters for each alert level.
GreaterThanOrEqualToThreshold
Escalations.Warn.ComparisonOperatorstringNo

The 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 previous monitoring cycle

Valid values of N: 1 to 200.

Note You must select at least one of the Critical, Warn, and Info alert levels and specify the Statistics, ComparisonOperator, Threshold, and Times parameters for each alert level.
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.

Note You must select at least one of the Critical, Warn, and Info alert levels and specify the Statistics, ComparisonOperator, Threshold, and Times parameters for each alert level.
1
Escalations.Warn.StatisticsstringNo

The statistical method for the Warn-level alert.

Valid values of N: 1 to 200.

The value of this parameter is determined by the Statistics column corresponding to the MetricName parameter of the specified cloud service. The value of this parameter can be Maximum, Minimum, or Average. For more information about how to obtain the value of this parameter, see Appendix 1: Metrics.

Note You must select at least one of the Critical, Warn, and Info alert levels and specify the Statistics, ComparisonOperator, Threshold, and Times parameters for each alert level.
Average

Response parameters

ParameterTypeDescriptionExample
object

The data returned.

Codeinteger

The status code.

Note The status code 200 indicates that the request was successful.
200
Messagestring

The error message.

The Request is not authorization.
RequestIdstring

The request ID.

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

Indicates whether the request was successful. Valid values:

  • true
  • false
true
Idlong

The ID of the alert template.

12345

Examples

Sample success responses

JSONformat

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

Error codes

HTTP status codeError codeError messageDescription
206%s%s-
400InvalidQueryParameter%s-
401AccessDeniedExceptionYou donot have sufficient access to perform this action.-
402LimitExceededThe quota for this customer had been reached.-
403InvalidClientTokenIdnot allow this operation.No permission
409ResourceConflictConcurrent modification of resources.-
409ResourceExistResources already exist.-
412ResourcesOverLimitResources over limit.-
429Throttli∂ngExceptionThe request was denied due to request throttling.-
500InternalFailure%s-

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

Change history

Change timeSummary of changesOperation
No change history