All Products
Search
Document Center

CloudMonitor:PutResourceMetricRules

Last Updated:Mar 01, 2024

Creates multiple alert rules for the specified metric of a specified resource.

Operation description

This topic provides an example on how to create a threshold-triggered alert rule for the cpu_total metric of an Elastic Compute Service (ECS) instance whose ID is i-uf6j91r34rnwawoo****. The namespace of ECS metrics is acs_ecs_dashboard. The alert contact group of the alert rule is ECS_Group. The name of the alert rule is test123. The ID of the alert rule is a151cd6023eacee2f0978e03863cc1697c89508****. The statistical method for Critical-level alerts is Average. The comparison operator for Critical-level alerts is GreaterThanOrEqualToThreshold. The threshold for Critical-level alerts is 90. The consecutive number of times for which the metric value meets the trigger condition before a Critical-level alert is triggered is 3.

Debugging

OpenAPI Explorer automatically calculates the signature value. For your convenience, we recommend that you call this operation in OpenAPI Explorer.

Authorization information

There is currently no authorization information disclosed in the API.

Request parameters

ParameterTypeRequiredDescriptionExample
Rulesobject []Yes

The threshold-triggered alert rules.

Valid values of N: 1 to 500.

Escalations.Info.ThresholdstringNo

The threshold for Info-level alerts.

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.
90
MetricNamestringNo

The metric name.

Valid values of N: 1 to 500.

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

cpu_total
Escalations.Warn.ThresholdstringNo

The threshold for Warn-level alerts.

Valid values of N: 1 to 500.

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.
90
EffectiveIntervalstringNo

The time period during which the alert rule is effective.

Valid values of N: 1 to 500.

00:00-23:59
NoEffectiveIntervalstringNo

The time period during which the alert rule is ineffective.

Valid values of N: 1 to 500.

00:00-06:00
RuleIdstringYes

The ID of the alert rule.

Valid values of N: 1 to 500.

You can specify a new ID or the ID of an existing alert rule. For information about how to query the ID of an alert rule, see DescribeMetricRuleList .

Note If you specify a new ID, a threshold-triggered alert rule is created.
a151cd6023eacee2f0978e03863cc1697c89508****
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 500.

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.
3
Escalations.Critical.ThresholdstringNo

The threshold for Critical-level alerts.

Valid values of N: 1 to 500.

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.
90
Escalations.Critical.StatisticsstringNo

The statistical methods for Critical-level alerts.

Valid values of N: 1 to 500.

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.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 last monitoring cycle

Valid values of N: 1 to 500.

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

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.
3
ResourcesstringYes

The information about the resource. Example: [{"instanceId":"i-uf6j91r34rnwawoo****"}] or [{"userId":"100931896542****"}].

Valid values of N: 1 to 500.

For more information about the supported dimensions that are used to query resources, see Appendix 1: Metrics.

[{"instanceId":"i-uf6j91r34rnwawoo****"}]
SilenceTimeintegerNo

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

Unit: seconds. Default value: 86400.

Valid values of N: 1 to 500.

Note If an alert is not cleared after the mute period ends, CloudMonitor resends an alert notification.
86400
WebhookstringNo

The callback URL to which a POST request is sent when an alert is triggered based on the alert rule.

Valid values of N: 1 to 500.

https://alert.aliyun.com.com:8080/callback
ContactGroupsstringYes

The alert contact groups. The alert notifications are sent to the alert contacts in the alert contact group.

Valid values of N: 1 to 500.

Note An alert contact group can contain one or more alert contacts. For information about how to create alert contacts and alert contact groups, see PutContact and PutContactGroup .
ECS_Group
NamespacestringYes

The namespace of the cloud service.

Valid values of N: 1 to 500.

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

acs_ecs_dashboard
EmailSubjectstringNo

The subject of the alert notification email.

Valid values of N: 1 to 500.

PeriodstringNo

The statistical period of the metric.

Unit: seconds. The default value is the interval at which the monitoring data of the metric is collected.

Valid values of N: 1 to 500.

Note For information about how to query the statistical period of a metric, see Appendix 1: Metrics.
60
RuleNamestringYes

The name of the alert rule.

Valid values of N: 1 to 500.

You can specify a new name or the name of an existing alert rule. For information about how to query the name of an alert rule, see DescribeMetricRuleList .

Note If you specify a new name, a threshold-triggered alert rule is created.
test123
Escalations.Info.StatisticsstringNo

The statistical methods for Info-level alerts.

Valid values of N: 1 to 500.

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

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.
3
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 last monitoring cycle

Valid values of N: 1 to 500.

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
IntervalstringNo

The interval at which alerts are triggered based on the alert rule.

Unit: seconds.

Valid values of N: 1 to 500.

Note For information about how to query the statistical period of a metric, see Appendix 1: Metrics.
60
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 last monitoring cycle

Valid values of N: 1 to 500.

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

The statistical methods for Warn-level alerts.

Valid values of N: 1 to 500.

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
NoDataPolicystringNo

The method that is used to handle alerts when no monitoring data is found. Valid values:

  • KEEP_LAST_STATE (default): No operation is performed.
  • INSUFFICIENT_DATA: An alert whose content is "Insufficient data" is triggered.
  • OK: The status is considered normal.

Valid values of N: 1 to 500.

KEEP_LAST_STATE
Labelsobject []No

If the metric meets the specified condition in the alert rule and CloudMonitor sends an alert notification, the tag is also written to the metric and displayed in the alert notification.

KeystringNo

The tag key.

tagKey1
ValuestringNo

The tag value.

Note You can use a template parameter to specify a tag value. CloudMonitor replaces the value of the template parameter with an actual tag value.
ECS

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

Response parameters

ParameterTypeDescriptionExample
object

None.

Codestring

The response code.

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

The error message returned.

The request processing has failed due to some unknown error.
RequestIdstring

The request ID.

15D1440E-BF24-5A41-93E4-36864635179E
Successboolean

Indicates whether the request was successful. Valid values:

  • true
  • false
true
FailedListResultobject []

The alert rules that failed to be created for the resource.

RuleIdstring

The ID of the alert rule.

a151cd6023eacee2f0978e03863cc1697c89508****
Resultobject

The alert rule that failed to be created.

Codestring

The response code.

404
Messagestring

The error message returned.

The request processing has failed due to some unknown error.
Successboolean

Indicates whether the request was successful. Valid values:

  • true
  • false
false

Examples

Sample success responses

JSONformat

{
  "Code": "200",
  "Message": "The request processing has failed due to some unknown error.",
  "RequestId": "15D1440E-BF24-5A41-93E4-36864635179E",
  "Success": true,
  "FailedListResult": {
    "Target": [
      {
        "RuleId": "a151cd6023eacee2f0978e03863cc1697c89508****",
        "Result": {
          "Code": "404",
          "Message": "The request processing has failed due to some unknown error.",
          "Success": false
        }
      }
    ]
  }
}

Error codes

HTTP status codeError codeError message
204%s%s
500InternalErrorThe request processing has failed due to some unknown error.

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

Change history

Change timeSummary of changesOperation
2021-10-28The Error code has changedsee changesets
Change itemChange content
Error CodesThe Error code has changed.
    delete Error Codes: 204
    delete Error Codes: 206
    delete Error Codes: 400
    delete Error Codes: 403
    delete Error Codes: 404
    delete Error Codes: 406
    delete Error Codes: 422
    delete Error Codes: 499
    delete Error Codes: 500
    delete Error Codes: 503