All Products
Search
Document Center

CloudMonitor:ApplyMetricRuleTemplate

Last Updated:Sep 29, 2024

Applies an alert template to an application group to generate an alert rule.

Operation description

In this example, the 700**** alert template is applied to the 123456 application group. For the generated alert rule, the ID is applyTemplate8ab74c6b-9f27-47ab-8841-de01dc08****, and the name is test123.

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

Request parameters

ParameterTypeRequiredDescriptionExample
SilenceTimelongNo

The mute period during which notifications are not repeatedly sent for an alert. Unit: seconds. Default value: 86400.

Note Only one alert notification is sent during each mute period even if the metric value exceeds the alert threshold several times.
86400
GroupIdlongYes

The ID of the application group to which the alert template is applied.

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

123456
TemplateIdsstringYes

The ID of the alert template.

For more information about how to query the IDs of alert templates, see DescribeMetricRuleTemplateList .

700****
EnableStartTimelongNo

The beginning of the time period during which the alert rule is effective. Valid values: 00 to 23. A value of 00 indicates 00:00 and a value of 23 indicates 23:00.

00
EnableEndTimelongNo

The end of the time period during which the alert rule is effective. Valid values: 00 to 23. A value of 00 indicates 00:59 and a value of 23 indicates 23:59.

23
NotifyLevellongNo

The alert notification method. Valid values:

Set the value to 4. A value of 4 indicates that alert notifications are sent by using TradeManager and DingTalk chatbots.

4
ApplyModestringNo

The mode in which the alert template is applied. Valid values:

  • GROUP_INSTANCE_FIRST: The metrics in the application group take precedence. If a metric specified in the alert template does not exist in the application group, the system does not generate an alert rule for the metric based on the alert template.
  • ALARM_TEMPLATE_FIRST: The metrics specified in the alert template take precedence. If a metric specified in the alert template does not exist in the application group, the system still generates an alert rule for the metric based on the alert template.
GROUP_INSTANCE_FIRST
WebhookstringNo

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

https://www.aliyun.com
AppendModestringNo

The template application policy. Valid values:

  • all (default): deletes all the rules that are created by using the alert template from the selected application group, and then creates alert rules based on the template.
  • append: deletes the rules that are created by using the alert template from the selected application group, and then creates alert rules based on the existing template.
all

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

Response parameters

ParameterTypeDescriptionExample
object
Codeinteger

The responses code.

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

The returned message.

The specified resource is not found.
RequestIdstring

The request ID.

3F897F3C-020A-4993-95B4-63ABB84F83E6
Resourceobject

The resources that are affected by the alert rule.

AlertResultsarray<object>

The details of the generated alert rule.

Resultobject
Codestring

The responses code.

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

The returned message.

alert rule is creating, please wait a few minutes.
RuleIdstring

The ID of the alert rule.

applyTemplate8ab74c6b-9f27-47ab-8841-de01dc08****
RuleNamestring

The name of the alert rule.

test123
Successboolean

Indicates whether the request was successful. Valid values:

  • true
  • false
true
GroupIdlong

The ID of the application group.

123456
Successboolean

Indicates whether the request was successful. Valid values:

  • true
  • false
true

Examples

Sample success responses

JSONformat

{
  "Code": 200,
  "Message": "The specified resource is not found.",
  "RequestId": "3F897F3C-020A-4993-95B4-63ABB84F83E6",
  "Resource": {
    "AlertResults": [
      {
        "Code": "200",
        "Message": "alert rule is creating, please wait a few minutes.",
        "RuleId": "applyTemplate8ab74c6b-9f27-47ab-8841-de01dc08****",
        "RuleName": "test123",
        "Success": true
      }
    ],
    "GroupId": 123456
  },
  "Success": true
}

Error codes

HTTP status codeError codeError message
400ParameterInvalidIllegal parameters.
403AccessForbiddenUser not authorized to operate on the specified resource.
404ResourceNotFound%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
2024-02-27The Error code has changed. The request parameters of the API has changedView Change Details