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

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

The ID of the application group.

TemplateIds String Yes 700****

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 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 method. Valid values:

Set the value to 4. The value 4 indicates that alert notifications are sent by using TradeManager 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 https://www.aliyun.com

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

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

Response parameters

Parameter Type Example Description
Code Integer 200

The HTTP status code.

Note The value 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. Valid values:

  • true: The call was successful.
  • false: The call failed.
Resource Struct

The resources that are affected by the alert rule.

AlertResults Array of Result

The details about the generated alert rule.

Code String 200

The HTTP status code.

Note The value 200 indicates that the call was successful.
Message String alert rule is creating, please wait a few minutes.

The returned message.

RuleId String applyTemplate8ab74c6b-9f27-47ab-8841-de01dc08****

The ID of the alert rule.

RuleName String test123

The name of the alert rule.

Success Boolean true

Indicates whether the call was successful. Valid values:

  • true: The call was successful.
  • false: The call failed.
GroupId Long 123456

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

Message String The specified resource is not found.

The error message.

Examples

Sample requests

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

Sample success responses

XML format

<ApplyMetricRuleTemplateResponse>
	  <RequestId>37D4037E-827E-4E66-87DF-F56A22F2884D</RequestId>
	  <Resource>
		    <GroupId>7756****</GroupId>
		    <AlertResults>
			      <Message>alert rule is creating, please wait a few minutes.</Message>
			      <RuleId>applyTemplate8ab74c6b-9f27-47ab-8841-de01dc08****</RuleId>
			      <Code>202</Code>
			      <RuleName>test123</RuleName>
			      <Success>true</Success>
		    </AlertResults>
	  </Resource>
	  <Code>200</Code>
	  <Success>true</Success>
</ApplyMetricRuleTemplateResponse>

JSON format

{
	"RequestId": "37D4037E-827E-4E66-87DF-F56A22F2884D",
	"Resource": {
		"GroupId": "7756****",
		"AlertResults": [
			{
				"Message": "alert rule is creating, please wait a few minutes.",
				"RuleId": "applyTemplate8ab74c6b-9f27-47ab-8841-de01dc08****",
				"Code": 202,
				"RuleName": "test123",
				"Success": true
			}
		]
	},
	"Code": 200,
	"Success": true
}

Error codes

HttpCode Error code Error message Description
404 ResourceNotFound The specified resource is not found. The error message returned because the specified resource is not found.

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