You can call this operation to create a performance metric alert rule for a resource. Call CreateGroupMetricRules to create an alert rule for an application group.

For more information about how to set request parameters such as Namespace, MetricName, and Dimensions required to create an alert rule, call DescribeMetricMetaList or see Preset metrics reference.

Debugging

You can use API Explorer to perform debugging. API Explorer allows you to perform various operations to simplify API usage. For example, you can retrieve APIs, call APIs, and dynamically generate SDK example code.

Request parameters

Parameter Type Required Example Description
ContactGroups String Yes Default alert contact group

The alert contact group. Multiple groups must be separated with commas (,).

MetricName String Yes cpu_total

The name of the metric. For more information, call DescribeMetricMetaList or see Preset metrics reference.

Namespace String Yes acs_ecs_dashboard

The data namespace of the service. For more information, call DescribeMetricMetaList or see Preset metrics reference.

Resources String Yes [{"instanceId":"xxxxxxx"}]

The resource to be associated with the alert rule.

RuleId String Yes a151cd6023eacee2f0978e03863cc1697c89508****

The ID of the alert rule. The IDs of alert rules are generated by callers to ensure uniqueness. You can specify an existing ID to modify the corresponding alert rule or specify a new ID to create an alert rule.

Action String No PutResourceMetricRule

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

RuleName String No My alert rule

The name of the alert rule.

Webhook String No http://ww.aliyun.com

The URL of the callback triggered when an alert occurs. POST requests are sent to the URL.

EffectiveInterval String No 00:00-23:59

The period when the alert rule is effective.

NoEffectiveInterval String No 00:00-06:00

The period when the alert rule is ineffective.

SilenceTime Integer No 86400

The mute duration in which no new alerts are sent even if the trigger conditions are met. Unit: second. Default value: 86400 (one day). Minimum value: 3600 (one hour). Only one alert is sent in each mute duration.

Interval String No 60

The detection period of the alert rule. Unit: second. The default value is the highest frequency at which the metric is polled.

EmailSubject String No An alert occurs

The subject of the alert notification email.

Period String No 60

The aggregation period of monitoring data. Unit: second. The default value is the highest frequency at which the metric is polled. Typically, you do not need to specify the aggregation period.

Escalations.Critical.Statistics String No Average

The statistical method for critical-level alerts.

Escalations.Critical.ComparisonOperator String No GreaterThanOrEqualToThreshold

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

  • GreaterThanOrEqualToThreshold
  • GreaterThanThreshold
  • LessThanOrEqualToThreshold
  • LessThanThreshold
  • NotEqualToThreshold
  • GreaterThanYesterday
  • LessThanYesterday
  • GreaterThanLastWeek
  • LessThanLastWeek
  • GreaterThanLastPeriod
  • LessThanLastPeriod
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 exceeds the threshold for critical-level alerts before an alert is triggered.

Escalations.Warn.Statistics String No Average

The statistical method for warn-level alerts.

Escalations.Warn.ComparisonOperator String No GreaterThanOrEqualToThreshold

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

  • GreaterThanOrEqualToThreshold
  • GreaterThanThreshold
  • LessThanOrEqualToThreshold
  • LessThanThreshold
  • NotEqualToThreshold
  • GreaterThanYesterday
  • LessThanYesterday
  • GreaterThanLastWeek
  • LessThanLastWeek
  • GreaterThanLastPeriod
  • LessThanLastPeriod
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 exceeds the threshold for warn-level alerts before an alert is triggered.

Escalations.Info.Statistics String No Average

The statistical method for info-level alerts.

Escalations.Info.ComparisonOperator String No GreaterThanOrEqualToThreshold

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

  • GreaterThanOrEqualToThreshold
  • GreaterThanThreshold
  • LessThanOrEqualToThreshold
  • LessThanThreshold
  • NotEqualToThreshold
  • GreaterThanYesterday
  • LessThanYesterday
  • GreaterThanLastWeek
  • LessThanLastWeek
  • GreaterThanLastPeriod
  • LessThanLastPeriod
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 exceeds the threshold for info-level alerts before an alert is triggered.

Response parameters

Parameter Type Example Description
Code String 200

The status code. A value of 200 indicates that the call is successful.

Message String success

The error message.

RequestId String 65D50468-ECEF-48F1-A6E1-D952E89D9436

The request ID for troubleshooting.

Success Boolean true

Indicates whether the call is successful. A value of true indicates that the call is successful. A value of false indicates that the call has failed.

Examples

Sample requests


http(s)://[Endpoint]/? Action=PutResourceMetricRule
&ContactGroups=Default alert contact group
&MetricName=cpu_total
&Namespace=acs_ecs_dashboard 
&Resources=[{"instanceId":"xxxxxxx"}]
&RuleId=a151cd6023eacee2f0978e03863cc1697c89508****
&RuleName=My alert rule
&<Common request parameters>

Successful response examples

XML format

<PutResourceMetricRuleResponse>
  <Code>200</Code>
  <Message>success</Message>
  <RequestId>65D50468-ECEF-48F1-A6E1-D952E89D9436</RequestId>
  <Success>true</Success> 
</PutResourceMetricRuleResponse>

JSON format

{
	"Message":"success",
	"RequestId":"65D50468-ECEF-48F1-A6E1-D952E89D9436",
	"Success":true,
	"Code":"200"
}

Error code

View error codes