All Products
Search
Document Center

CloudMonitor:PutGroupMetricRule

Last Updated:Jul 26, 2024

Creates or modifies an alert rule for an application group.

Operation description

This topic provides an example on how to create an alert rule for the cpu_total metric of Elastic Compute Service (ECS) in the 17285**** application group. The ID of the alert rule is 123456. The name of the alert rule is Rule_test. The alert level is Critical. The statistical method is Average. The alert threshold comparator is GreaterThanOrEqualToThreshold. The alert threshold is 90. The number of alert retries is 3. The returned result shows that the alert rule is created and the alert rule ID is 123456.

Debugging

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

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

Request parameters

ParameterTypeRequiredDescriptionExample
GroupIdstringYes

The application group ID.

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

17285****
RuleIdstringYes

The ID of the alert rule.

  • When you create an alert rule for the application group, enter the ID of the alert rule.
  • When you modify a specified alert rule in the application group, you must obtain the ID of the alert rule. For information about how to obtain the ID of an alert rule, see DescribeMetricRuleList .
123456
CategorystringNo

The abbreviation of the cloud service name.

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
RuleNamestringYes

The name of the alert rule.

  • When you create an alert rule for the application group, enter the name of the alert rule.
  • When you modify a specified alert rule in the application group, you must obtain the name of the alert rule. For more information about how to obtain the name of an alert rule, see DescribeMetricRuleList .
Rule_01
NamespacestringYes

The namespace of the cloud service.

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

acs_ecs_dashboard
MetricNamestringYes

The metric name.

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

cpu_total
DimensionsstringNo

The first-level dimension of the alert rule in the application group.

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

[{"instanceId":"i-m5e1qg6uo38rztr4****"}]
ExtraDimensionJsonstringNo

The second-level or third-level dimension of the alert rule in the application group.

Set the value to a set of key-value pairs, for example, port:80 or /dev/xvda:d-m5e6yphgzn3aprwu****.

If the first-level dimension of the alert rule is instanceId:i-m5e1qg6uo38rztr4****, its second-level dimension is the /dev/xvda:d-m5e6yphgzn3aprwu**** disk in the instance.

{"/dev/xvda":"d-m5e6yphgzn3aprwu****"}
EffectiveIntervalstringNo

The time period during which the alert rule is effective.

05:31-23:59
NoEffectiveIntervalstringNo

The time period during which the alert rule is ineffective.

00:00-05:30
SilenceTimeintegerNo

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

Unit: seconds. Default value: 86400.

86400
PeriodstringNo

The aggregation period of the metric data.

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

60
IntervalstringNo

The interval at which CloudMonitor checks whether the alert rule is triggered. Unit: seconds.

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
WebhookstringNo

The callback URL.

The callback URL must be accessible over the Internet. CloudMonitor sends a POST request to push an alert notification to the callback URL that you specify. Only HTTP requests are supported.

https://www.aliyun.com
EmailSubjectstringNo

The subject of the alert notification email.

ContactGroupsstringNo

The alert contact group.

ECS_Group
Escalations.Critical.StatisticsstringNo

The statistical methods for Critical-level alerts. Separate multiple statistical methods with commas (,).

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.

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 last monitoring cycle
GreaterThanOrEqualToThreshold
Escalations.Critical.ThresholdstringNo

The threshold for Critical-level alerts.

90
Escalations.Critical.TimesintegerNo

The consecutive number of times for which the metric value meets the alert condition before a Critical-level alert is triggered.

3
Escalations.Warn.StatisticsstringNo

The statistical methods for Warn-level alerts. Separate multiple statistical methods with commas (,).

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.

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
GreaterThanOrEqualToThreshold
Escalations.Warn.ThresholdstringNo

The threshold for Warn-level alerts.

90
Escalations.Warn.TimesintegerNo

The consecutive number of times for which the metric value meets the alert condition before a Warn-level alert is triggered.

3
Escalations.Info.StatisticsstringNo

The statistical methods for Info-level alerts. Separate multiple statistical methods with commas (,).

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.

Average
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
GreaterThanOrEqualToThreshold
Escalations.Info.ThresholdstringNo

The threshold for Info-level alerts.

90
Escalations.Info.TimesintegerNo

The consecutive number of times for which the metric value meets the alert condition before an Info-level alert is triggered.

3
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.
KEEP_LAST_STATE
Labelsarray<object>No

The tags of the alert rule.

The specified tag is contained in alert notifications.

objectNo
KeystringNo

The tag key of the alert rule.

key1
ValuestringNo

The tag value of the alert rule.

value1

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

Response parameters

ParameterTypeDescriptionExample
object

None.

Codestring

The HTTP 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.

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

Indicates whether the request was successful. Valid values:

  • true
  • false
true
Resultobject

The result of the request.

RuleIdstring

The ID of the alert rule.

123456

Examples

Sample success responses

JSONformat

{
  "Code": "200",
  "Message": "The Request is not authorization.",
  "RequestId": "461CF2CD-2FC3-4B26-8645-7BD27E7D0F1D",
  "Success": true,
  "Result": {
    "RuleId": "123456"
  }
}

Error codes

HTTP status codeError codeError message
204%s%s

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

Change history

Change timeSummary of changesOperation
2023-12-13The Error code has changed. The request parameters of the API has changedView Change Details
2021-09-14The Error code has changed. The request parameters of the API has changedView Change Details