Creates multiple threshold alert rules for a specified metric of a specified resource by calling the PutResourceMetricRules operation.
Operation description
本文将提供一个示例,为云服务器 ECS acs_ecs_dashboard的实例i-uf6j91r34rnwawoo****中的监控项cpu_total设置阈值报警规则。该报警规则的报警联系组为ECS_Group、报警规则名称为test123、报警规则 ID 为a151cd6023eacee2f0978e03863cc1697c89508****、Critical 级别的统计方法为Average、Critical 级别的比较符为GreaterThanOrEqualToThreshold、Critical 级别的阈值为90和 Critical 级别的报警重试次数为3。
2024-08-15 增加 Statistics 校验,统计值只能填对应指标的 Statistics。关于如何获取该参数的取值,请参见云产品监控项。
Try it now
Test
RAM authorization
|
Action |
Access level |
Resource type |
Condition key |
Dependent action |
|
cms:PutResourceMetricRules |
create |
*All Resource
|
None | None |
Request parameters
|
Parameter |
Type |
Required |
Description |
Example |
| Rules |
array<object> |
Yes |
The list of threshold alert rules. Valid values of N: 1 to 50. |
|
|
array<object> |
No |
无。 |
||
| Escalations.Info.Threshold |
string |
No |
Info 级别报警阈值。 Note
报警级别 Critical(严重)、Warn(警告)或 Info(信息)至少设置一个,且该报警级别中的参数 Statistics、ComparisonOperator、Threshold 和 Times 必须同时设置。 |
90 |
| MetricName |
string |
No |
监控项名称。 N 的取值范围:1~50。 关于如何查询监控项名称,请参见云产品监控项。 |
cpu_total |
| Escalations.Warn.Threshold |
string |
No |
Warn 级别报警阈值。 N 的取值范围:1~50。 Note
报警级别 Critical(严重)、Warn(警告)或 Info(信息)至少设置一个,且该报警级别中的参数 Statistics、ComparisonOperator、Threshold 和 Times 必须同时设置。 |
90 |
| EffectiveInterval |
string |
No |
报警规则的生效时间范围。 N 的取值范围:1~50。 |
00:00-23:59 |
| NoEffectiveInterval |
string |
No |
报警规则的失效时间范围。 N 的取值范围:1~50。 |
00:00-06:00 |
| RuleId |
string |
Yes |
报警规则 ID。 N 的取值范围:1~50。 您可以输入新的报警规则 ID,也可以使用云监控已存在的报警规则 ID。关于如何查询报警规则 ID,请参见 DescribeMetricRuleList 。 Note
输入新的报警规则 ID,表示创建一条阈值报警规则。 |
a151cd6023eacee2f0978e03863cc1697c89508**** |
| Escalations.Critical.Times |
integer |
No |
Critical 级别报警重试次数。 N 的取值范围:1~50。 Note
报警级别 Critical(严重)、Warn(警告)或 Info(信息)至少设置一个,且该报警级别中的参数 Statistics、ComparisonOperator、Threshold 和 Times 必须同时设置。 |
3 |
| Escalations.Critical.Threshold |
string |
No |
Critical 级别报警阈值。 N 的取值范围:1~50。 Note
报警级别 Critical(严重)、Warn(警告)或 Info(信息)至少设置一个,且该报警级别中的参数 Statistics、ComparisonOperator、Threshold 和 Times 必须同时设置。 |
90 |
| Escalations.Critical.Statistics |
string |
No |
Critical 级别报警统计方法。 N 的取值范围:1~50。 该参数的取值由指定云产品的 Note
报警级别 Critical(严重)、Warn(警告)或 Info(信息)至少设置一个,且该报警级别中的参数 Statistics、ComparisonOperator、Threshold 和 Times 必须同时设置。 |
Average |
| Escalations.Warn.ComparisonOperator |
string |
No |
Warn 级别阈值比较符。取值:
N 的取值范围:1~50。 Note
报警级别 Critical(严重)、Warn(警告)或 Info(信息)至少设置一个,且该报警级别中的参数 Statistics、ComparisonOperator、Threshold 和 Times 必须同时设置。 |
GreaterThanOrEqualToThreshold |
| Escalations.Info.Times |
integer |
No |
Info 级别报警重试次数。 N 的取值范围:1~50。 Note
报警级别 Critical(严重)、Warn(警告)或 Info(信息)至少设置一个,且该报警级别中的参数 Statistics、ComparisonOperator、Threshold 和 Times 必须同时设置。 |
3 |
| Resources |
string |
Yes |
资源信息,例如: N 的取值范围:1~50。 关于资源信息支持的维度 Dimensions,请参见云产品监控项。 |
[{"instanceId":"i-uf6j91r34rnwawoo****"}] |
| SilenceTime |
integer |
No |
通道沉默周期。 单位:秒,默认值:86400。 N 的取值范围:1~50。 Note
通道沉默周期是指报警发生后未恢复正常,间隔多久重新发送一次报警通知。 |
86400 |
| Webhook |
string |
No |
报警发生回调时指定的 URL 地址,向 URL 发送 POST 请求。 N 的取值范围:1~50。 |
https://alert.aliyun.com.com:8080/callback |
| ContactGroups |
string |
Yes |
报警联系组。报警通知会发送给该报警联系组中的报警联系人。 N 的取值范围:1~50。 Note
报警联系组是一组报警联系人,可以包含一个或多个报警联系人。关于如何创建报警联系人和报警联系组,请参见 PutContact 和 PutContactGroup 。 |
ECS_Group |
| Namespace |
string |
Yes |
云产品的数据命名空间。 N 的取值范围:1~50。 关于如何查询云产品的数据命名空间,请参见云产品监控项。 |
acs_ecs_dashboard |
| EmailSubject |
string |
No |
报警邮件主题。 N 的取值范围:1~50。 |
ECS instance alert |
| Period |
string |
No |
监控项的统计周期。 单位:秒。默认为监控项的原始上报周期。 N 的取值范围:1~50。 Note
关于如何查询监控项的统计周期,请参见云产品监控项。 |
60 |
| RuleName |
string |
Yes |
报警规则名称。 N 的取值范围:1~50。 您可以输入新的报警规则名称,也可以使用云监控已存在的报警规则名称。关于如何查询报警规则名称,请参见 DescribeMetricRuleList 。 Note
输入新的报警规则名称,表示创建一条阈值报警规则。 |
test123 |
| Escalations.Info.Statistics |
string |
No |
Info 级别报警统计方法。 N 的取值范围:1~50。 该参数的取值由指定云产品的 Note
报警级别 Critical(严重)、Warn(警告)或 Info(信息)至少设置一个,且该报警级别中的参数 Statistics、ComparisonOperator、Threshold 和 Times 必须同时设置。 |
Average |
| Escalations.Warn.Times |
integer |
No |
Warn 级别报警重试次数。 N 的取值范围:1~50。 Note
报警级别 Critical(严重)、Warn(警告)或 Info(信息)至少设置一个,且该报警级别中的参数 Statistics、ComparisonOperator、Threshold 和 Times 必须同时设置。 |
3 |
| Escalations.Info.ComparisonOperator |
string |
No |
Info 级别阈值比较符。取值:
N 的取值范围:1~50。 Note
报警级别 Critical(严重)、Warn(警告)或 Info(信息)至少设置一个,且该报警级别中的参数 Statistics、ComparisonOperator、Threshold 和 Times 必须同时设置。 |
GreaterThanOrEqualToThreshold |
| Interval |
string |
No |
报警规则的触发周期。 单位:秒。 N 的取值范围:1~50。 Note
关于如何查询监控项的统计周期,请参见云产品监控项。 |
60 |
| Escalations.Critical.ComparisonOperator |
string |
No |
Critical 级别阈值比较符。取值:
N 的取值范围:1~50。 Note
报警级别 Critical(严重)、Warn(警告)或 Info(信息)至少设置一个,且该报警级别中的参数 Statistics、ComparisonOperator、Threshold 和 Times 必须同时设置。 |
GreaterThanOrEqualToThreshold |
| Escalations.Warn.Statistics |
string |
No |
Warn 级别报警统计方法。 N 的取值范围:1~50。 该参数的取值由指定云产品的 Note
报警级别 Critical(严重)、Warn(警告)或 Info(信息)至少设置一个,且该报警级别中的参数 Statistics、ComparisonOperator、Threshold 和 Times 必须同时设置。 |
Average |
| NoDataPolicy |
string |
No |
无监控数据时报警的处理方式。取值:
N 的取值范围:1~50。 |
KEEP_LAST_STATE |
| Labels |
array<object> |
No |
当监控项达到报警条件并进行报警时,标签同时写入监控项,在报警通知中进行展示。 |
|
|
object |
No |
无。 |
||
| Key |
string |
No |
标签键。 |
tagKey1 |
| Value |
string |
No |
标签值。 Note
标签值支持模板参数,将模板参数替换为实际标签值。 |
ECS |
| SendOK |
boolean |
No |
是否发送恢复通知 |
true |
For more information about common request parameters, see Common parameters.
Response elements
|
Element |
Type |
Description |
Example |
|
object |
无。 |
||
| Code |
string |
状态码。 Note
200 表示成功。 |
200 |
| Message |
string |
错误信息。 |
The request processing has failed due to some unknown error. |
| RequestId |
string |
请求 ID。 |
15D1440E-BF24-5A41-93E4-36864635179E |
| Success |
boolean |
操作是否成功。取值:
|
true |
| FailedListResult |
object |
||
| Target |
array<object> |
为资源设置报警规则的失败结果列表。 |
|
|
array<object> |
无。 |
||
| RuleId |
string |
The result of the operation for this alert rule. |
a151cd6023eacee2f0978e03863cc1697c89508**** |
| Result |
object |
The status code. |
|
| Code |
string |
The error message. |
404 |
| Message |
string |
Indicates whether the alert rule was successfully set. Valid values: |
The request processing has failed due to some unknown error. |
| Success |
boolean |
Indicates whether the alert rule was successfully set. Valid values:
|
false |
Examples
Success response
JSON format
{
"Code": "200",
"Message": "The request processing has failed due to some unknown error.",
"RequestId": "15D1440E-BF24-5A41-93E4-36864635179E",
"Success": true,
"FailedListResult": {
"Target": [
{
"RuleId": "a151cd6023eacee2f0978e03863cc1697c89508****",
"Result": {
"Code": "404",
"Message": "The request processing has failed due to some unknown error.",
"Success": false
}
}
]
}
}
Error codes
|
HTTP status code |
Error code |
Error message |
Description |
|---|---|---|---|
| 400 | %s | %s | |
| 422 | %s | %s | |
| 499 | %s | %s | |
| 500 | InternalError | The request processing has failed due to some unknown error. | |
| 204 | %s | %s | |
| 403 | %s | %s | |
| 206 | %s | %s | |
| 404 | %s | %s | |
| 503 | %s | %s | |
| 406 | %s | %s |
See Error Codes for a complete list.
Release notes
See Release Notes for a complete list.