ApplyMetricRuleTemplate
Applies an alert template to an application group to generate alert rules.
Operation description
This topic provides an example to show how to apply the alert template 700**** to the application group 123456. The ID of the generated alert rule is applyTemplate8ab74c6b-9f27-47ab-8841-de01dc08****, and the name is test123.
Try it now
Test
RAM authorization
|
Action |
Access level |
Resource type |
Condition key |
Dependent action |
|
cms:ApplyMetricRuleTemplate |
create |
*MetricRuleTemplate
|
None | None |
Request parameters
|
Parameter |
Type |
Required |
Description |
Example |
| SilenceTime |
integer |
No |
The mute for. Unit: seconds. Default value: 86400. Note
If the monitoring data continuously exceeds the threshold of the alert rule, the system will send only one alert notification within each epoch. |
86400 |
| GroupId |
integer |
Yes |
The ID of the application group. For more information about how to obtain the ID of an application group, see DescribeMonitorGroups. |
123456 |
| TemplateIds |
string |
Yes |
The ID of the alert template. For more information about how to obtain the ID of an alert template, see DescribeMetricRuleTemplateList. |
700**** |
| EnableStartTime |
integer |
No |
The start hour of the effective period for the alert. The value is a two-digit string, such as "00", "09", or "23". Valid values: 00 to 23, which represent 00:00 to 23:00. The default time zone is UTC+8. |
00 |
| EnableEndTime |
integer |
No |
The end hour of the effective period for the alert. The value is a two-digit string, such as "00", "18", or "23". Valid values: 00 to 23. The value specifies the hour when the effective period ends, and the period actually ends at the 59th minute of the hour. For example, "23" indicates that the effective period ends at 23:59. The default time zone is UTC+8. |
23 |
| NotifyLevel |
integer |
No |
The alert notification method. Valid values:
|
4 |
| ApplyMode |
string |
No |
The application mode of the template. Valid values:
|
GROUP_INSTANCE_FIRST |
| Webhook |
string |
No |
The webhook URL to which an HTTP POST request is sent when an alert is triggered. |
https://www.aliyun.com |
| AppendMode |
string |
No |
The application policy of the template. Valid values:
|
all |
| DryRun |
boolean |
No |
Specifies whether to only precheck the request. Valid values:
|
false |
For more information about common request parameters, see Common parameters.
Response elements
|
Element |
Type |
Description |
Example |
|
object |
|||
| Code |
integer |
The HTTP status code. Note
200 indicates success. |
200 |
| Message |
string |
The error message. |
The specified resource is not found. |
| RequestId |
string |
The request ID. |
3F897F3C-020A-4993-95B4-63ABB84F83E6 |
| Success |
boolean |
Indicates whether the operation was successful. Valid values:
|
true |
| Resource |
object |
The resources affected by the alert rules. |
|
| GroupId |
integer |
The ID of the application group. |
123456 |
| AlertResults |
array<object> |
The detailed results of the generated alert rules. |
|
|
object |
The detailed results of the generated alert rules. |
||
| Code |
string |
The HTTP status code. Note
200 indicates success. |
200 |
| Message |
string |
The returned message. |
alert rule is creating, please wait a few minutes. |
| Success |
boolean |
Indicates whether the operation was successful. Valid values:
|
true |
| RuleName |
string |
The name of the alert rule. |
test123 |
| RuleId |
string |
The ID of the alert rule. |
applyTemplate8ab74c6b-9f27-47ab-8841-de01dc08**** |
Examples
Success response
JSON format
{
"Code": 200,
"Message": "The specified resource is not found.",
"RequestId": "3F897F3C-020A-4993-95B4-63ABB84F83E6",
"Success": true,
"Resource": {
"GroupId": 123456,
"AlertResults": [
{
"Code": "200",
"Message": "alert rule is creating, please wait a few minutes.",
"Success": true,
"RuleName": "test123",
"RuleId": "applyTemplate8ab74c6b-9f27-47ab-8841-de01dc08****"
}
]
}
}
Error codes
|
HTTP status code |
Error code |
Error message |
Description |
|---|---|---|---|
| 400 | ParameterInvalid | Illegal parameters. | |
| 412 | DryRunOperation | %s. | dryRun Pre-Verification Results |
| 500 | InternalError | The request processing has failed due to some unknown error. | |
| 403 | AccessForbidden | User not authorized to operate on the specified resource. | |
| 404 | ResourceNotFound | %s |
See Error Codes for a complete list.
Release notes
See Release Notes for a complete list.