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

Debugging

OpenAPI Explorer automatically calculates the signature value. For your convenience, we recommend that you call this operation in OpenAPI Explorer. OpenAPI Explorer dynamically generates the sample code of the operation for different SDKs.

Request parameters

Parameter Type Required Example Description
Action String Yes ApplyMetricRuleTemplate

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

GroupId Long Yes 12345

The ID of the application group.

TemplateIds String Yes 123

The ID of the alert template.

SilenceTime Long No 86400

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 consecutively exceeds the alert threshold several times.
EnableStartTime Long No 00

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

EnableEndTime Long No 23

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

NotifyLevel Long No 4

The alert notification methods. Valid values:

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

ApplyMode String No GROUP_INSTANCE_FIRST

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.
Webhook String No http://www.aliyun.com

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

Response parameters

Parameter Type Example Description
Code Integer 200

The HTTP status code.

Note The status code 200 indicates that the call was successful.
RequestId String 3F897F3C-020A-4993-95B4-63ABB84F83E6

The ID of the request.

Success Boolean true

Indicates whether the call was successful. The value true indicates a success. The value false indicates a failure.

Resource Struct N/A

The affected resources.

AlertResults Array N/A

The details of the generated alert rule.

Code String 200

The HTTP status code.

Note The status code 200 indicates that the call was successful.
GroupId Long 123456

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

Message String The Request is not authorization.

The returned message.

RuleId String applyTemplate1234****

The ID of the alert rule.

RuleName String ruleName1

The name of the alert rule.

Success Boolean true

Indicates whether the call was successful. The value true indicates a success. The value false indicates a failure.

GroupId Long 123456

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

Message String The Request is not authorization.

The returned message.

Examples

Sample requests

http(s)://[Endpoint]/? Action=ApplyMetricRuleTemplate
&GroupId=12345
&TemplateIds=123
&<Common request parameters>

Sample success responses

XML format

<ApplyMetricRuleTemplate>
          <RequestId>3F897F3C-020A-4993-95B4-63ABB84F83E6</RequestId>
          <Resource>
                <GroupId>123456</GroupId>
                <AlertResults>
                      <RuleId>applyTemplate1234****</RuleId>
                      <Code>200</Code>
                      <RuleName>ruleName1</RuleName>
                      <Success>true</Success>
                      <GroupId>123456</GroupId>
                </AlertResults>
          </Resource>
          <Code>200</Code>
          <Success>true</Success>
</ApplyMetricRuleTemplate>

JSON format

{
    "RequestId":"3F897F3C-020A-4993-95B4-63ABB84F83E6",
    "Resource":{
        "GroupId":"123456",
        "AlertResults":[
            {
                "RuleId":"applyTemplate1234****",
                "Code":"200",
                "RuleName":"ruleName1",
                "Success":"true",
                "GroupId":"123456"
            }]
    },
    "Code":"200",
    "Success":"true"
}

Error codes

For a list of error codes, visit the API Error Center.