创建或更新通知策略。
调试
您可以在OpenAPI Explorer中直接运行该接口,免去您计算签名的困扰。运行成功后,OpenAPI Explorer可以自动生成SDK代码示例。
调试
授权信息
请求参数
|
名称 |
类型 |
必填 |
描述 |
示例值 |
| Id |
integer |
否 |
通知策略 ID。
|
1234 |
| Name |
string |
是 |
通知策略名称。 |
notificationpolicy_test |
| MatchingRules |
string |
否 |
匹配告警事件规则。格式如下: |
[ { "matchingConditions": [ { "value": "test", "key": "alertname", "operator": "eq" } ] } ] |
| SendRecoverMessage |
boolean |
否 |
当告警下面全部事件都恢复时,告警状态是否自动恢复为已解决。当告警恢复时,系统将会发送通知给处理人。
|
true |
| GroupRule |
string |
否 |
设置事件分组。
|
{ "groupWait":5, "groupInterval":30, "groupingFields":["alertname"] } |
| NotifyRule |
string |
是 |
设置通知规则。格式如下: |
{ "notifyStartTime": "00:00", "notifyEndTime": "23:59", "notifyChannels": [ "dingTalk", "email", "sms", "tts", "webhook" ], "notifyObjects": [ { "notifyObjectType": "CONTACT", "notifyObjectId": 123, "notifyObjectName": "test", "notifyChannels": [ "email", "sms", "tts" ], } ] } |
| NotifyTemplate |
string |
否 |
通知模板。示例模板请参见表格下方说明。 |
{ "robotContent":"{{if .commonLabels.clustername }} > 集群名称:{{ .commonLabels.clustername }} {{ end }}{{if eq "app" .commonLabels._aliyun_arms_involvedObject_kind }} > 应用名称:{{ .commonLabels._aliyun_arms_involvedObject_name }} {{ end }}{{ for .alerts }} > {{ .annotations.message }} {{if .generatorURL }} [详情链接]({{.generatorURL}}) {{end}} {{if eq "true" .labels._aliyun_arms_is_denoise_filtered }} (疑似噪音) {{end}} {{end}}" } |
| EscalationPolicyId |
integer |
否 |
升级规则 ID。 |
123 |
| Repeat |
boolean |
否 |
对于长期未解决的告警是否发送重复通知。
|
true |
| RepeatInterval |
integer |
否 |
重复通知时间间隔,单位为秒。 |
600 |
| IntegrationId |
integer |
否 |
告警需要推送到的工单系统,填写工单系统的集成 ID。 |
34 |
| RegionId |
string |
否 |
地域 ID。 |
cn-hangzhou |
| DirectedMode |
boolean |
否 |
极简模式 |
false |
| State |
string |
否 |
通知策略是否启用,enable 启用,disable 停用 |
enable |
NotifyTemplate 默认通知模板示例
{
//邮件告警通知
"emailTitle":"{{ .commonLabels.alertname }}",
"emailContent":"告警名称:{{ .commonLabels.alertname }}{{if .commonLabels.clustername }} 集群名称:{{ .commonLabels.clustername }} {{ end }}{{if eq "app" .commonLabels._aliyun_arms_involvedObject_kind }} 应用名称:{{ .commonLabels._aliyun_arms_involvedObject_name }} {{ end }} 通知策略:{{ .dispatchRuleName }} 告警时间:{{ .startTime }} 告警内容:{{ for .alerts }} {{ .annotations.message }} {{if .generatorURL }} <a href="{{.generatorURL}}" > 详情链接</a> {{ end }} {{ end }}",
//邮件告警恢复通知
"emailRecoverTitle":"{{ .commonLabels.alertname }}",
"emailRecoverContent":"告警名称:{{ .commonLabels.alertname }}{{if .commonLabels.clustername }} 集群名称:{{ .commonLabels.clustername }} {{ end }}{{if eq "app" .commonLabels._aliyun_arms_involvedObject_kind }} 应用名称:{{ .commonLabels._aliyun_arms_involvedObject_name }} {{ end }} 通知策略:{{ .dispatchRuleName }} 恢复时间:{{ .endTime }} 告警内容:{{ for .alerts }} {{ .annotations.message }} {{if .generatorURL }} <a href="{{.generatorURL}}" > 详情链接</a> {{ end }} {{ end }}",
//短信告警通知
"smsContent":"发生{{ .level }}告警 告警名称:{{ .commonLabels.alertname }}{{if .commonLabels.clustername }} 集群名称:{{ .commonLabels.clustername }} {{ end }}{{if eq "app" .commonLabels._aliyun_arms_involvedObject_kind }} 应用名称:{{ .commonLabels._aliyun_arms_involvedObject_name }} {{ end }} 通知策略:{{ .dispatchRuleName }} 告警时间:{{ .startTime }} 告警内容:{{ for .alerts }} {{ .annotations.message }} {{ end }}",
//短信告警恢复通知
"smsRecoverContent":"告警已经恢复 告警名称:{{ .commonLabels.alertname }}{{if .commonLabels.clustername }} 集群名称:{{ .commonLabels.clustername }} {{ end }}{{if eq "app" .commonLabels._aliyun_arms_involvedObject_kind }} 应用名称:{{ .commonLabels._aliyun_arms_involvedObject_name }} {{ end }} 通知策略:{{ .dispatchRuleName }} 恢复时间:{{ .endTime }} 告警内容:{{ for .alerts }} {{ .annotations.message }} {{ end }}",
//电话告警通知
"ttsContent":"告警名称:{{ .commonLabels.alertname }}{{if .commonLabels.clustername }} 集群名称:{{ .commonLabels.clustername }} {{ end }}{{if eq "app" .commonLabels._aliyun_arms_involvedObject_kind }} 应用名称:{{ .commonLabels._aliyun_arms_involvedObject_name }} {{ end }} 通知策略:{{ .dispatchRuleName }} 告警时间:{{ .startTime }} 告警内容:{{ for .alerts }} {{ .annotations.message }} {{ end }}",
//电话告警恢复通知
"ttsRecoverContent":"告警名称:{{ .commonLabels.alertname }}{{if .commonLabels.clustername }} 集群名称:{{ .commonLabels.clustername }} {{ end }}{{if eq "app" .commonLabels._aliyun_arms_involvedObject_kind }} 应用名称:{{ .commonLabels._aliyun_arms_involvedObject_name }} {{ end }} 通知策略:{{ .dispatchRuleName }} 恢复时间:{{ .endTime }} 告警内容:{{ for .alerts }} {{ .annotations.message }} {{ end }}",
//机器人告警通知
"robotContent":"{{if .commonLabels.clustername }} > 集群名称:{{ .commonLabels.clustername }} {{ end }}{{if eq "app" .commonLabels._aliyun_arms_involvedObject_kind }} > 应用名称:{{ .commonLabels._aliyun_arms_involvedObject_name }} {{ end }}{{ for .alerts }} > {{ .annotations.message }} {{if .generatorURL }} [详情链接]({{.generatorURL}}) {{end}} {{if eq "true" .labels._aliyun_arms_is_denoise_filtered }} (疑似噪音) {{end}} {{end}}"
}
返回参数
|
名称 |
类型 |
描述 |
示例值 |
|
object |
Schema of Response |
||
| RequestId |
string |
请求 ID。 |
A5EC8221-08F2-4C95-9AF1-49FD998C**** |
| NotificationPolicy |
object |
通知策略对象。 |
|
| Id |
integer |
通知策略 ID。 |
1234 |
| Name |
string |
通知策略名称。 |
notificationpolicy_test |
| MatchingRules |
array<object> |
匹配告警事件规则。 |
|
|
array<object> |
|||
| MatchingConditions |
array<object> |
匹配条件。 |
|
|
object |
|||
| Key |
string |
匹配条件 Key。 |
altertname |
| Value |
string |
匹配条件 Value。 |
test |
| Operator |
string |
匹配条件聚合方式。
|
eq |
| SendRecoverMessage |
boolean |
当告警下面全部事件都恢复时,告警状态是否自动恢复为已解决。当告警恢复时,系统将会发送通知给处理人。
|
true |
| GroupRule |
object |
事件分组。 |
|
| GroupingFields |
array |
设置事件分组。
|
|
|
string |
分组字段。 |
["alertName","clustname"] |
|
| GroupWait |
integer |
分组等待时间,默认为 5 秒。 |
5 |
| GroupInterval |
integer |
分组间隔时间,默认为 30 秒。 |
30 |
| NotifyRule |
object |
通知规则。 |
|
| NotifyStartTime |
string |
通知时间段开始时间。 |
00:00 |
| NotifyEndTime |
string |
通知时间段结束时间。 |
23:59 |
| NotifyChannels |
array |
通知方式。 |
|
|
string |
通知方式。
|
["dingTalk", "email", "sms", "tts", "webhook"] |
|
| NotifyObjects |
array<object> |
通知对象列表。 |
|
|
object |
通知对象 |
||
| NotifyObjectType |
string |
通知对象类型。
|
CONTACT |
| NotifyObjectId |
integer |
通知对象 ID。 |
123 |
| NotifyObjectName |
string |
通知对象名称。 |
test |
| NotifyChannels |
array |
通知对象为联系人时的单独的联系方式 |
|
|
string |
通知方式。
|
sms |
|
| NotifyTemplate |
object |
通知模板。 |
|
| EmailTitle |
string |
邮件告警通知标题。 |
{{ .commonLabels.alertname }} |
| EmailContent |
string |
邮件告警通知内容。 |
告警名称:{{ .commonLabels.alertname }}{{if .commonLabels.clustername }} 集群名称:{{ .commonLabels.clustername }} {{ end }}{{if eq "app" .commonLabels._aliyun_arms_involvedObject_kind }} 应用名称:{{ .commonLabels._aliyun_arms_involvedObject_name }} {{ end }} 通知策略:{{ .dispatchRuleName }} 告警时间:{{ .startTime }} 告警内容:{{ for .alerts }} {{ .annotations.message }} {{if .generatorURL }} 详情链接 {{ end }} {{ end }} |
| EmailRecoverTitle |
string |
邮件告警恢复通知标题。 |
{{ .commonLabels.alertname }} |
| EmailRecoverContent |
string |
邮件告警恢复通知内容。 |
告警名称:{{ .commonLabels.alertname }}{{if .commonLabels.clustername }} 集群名称:{{ .commonLabels.clustername }} {{ end }}{{if eq "app" .commonLabels._aliyun_arms_involvedObject_kind }} 应用名称:{{ .commonLabels._aliyun_arms_involvedObject_name }} {{ end }} 通知策略:{{ .dispatchRuleName }} 恢复时间:{{ .endTime }} 告警内容:{{ for .alerts }} {{ .annotations.message }} {{if .generatorURL }} 详情链接 {{ end }} {{ end }} |
| SmsContent |
string |
短信告警通知内容。 |
发生{{ .level }}告警 告警名称:{{ .commonLabels.alertname }}{{if .commonLabels.clustername }} 集群名称:{{ .commonLabels.clustername }} {{ end }}{{if eq "app" .commonLabels._aliyun_arms_involvedObject_kind }} 应用名称:{{ .commonLabels._aliyun_arms_involvedObject_name }} {{ end }} 通知策略:{{ .dispatchRuleName }} 告警时间:{{ .startTime }} 告警内容:{{ for .alerts }} {{ .annotations.message }} {{ end }} |
| SmsRecoverContent |
string |
短信告警恢复通知内容。 |
告警已经恢复 告警名称:{{ .commonLabels.alertname }}{{if .commonLabels.clustername }} 集群名称:{{ .commonLabels.clustername }} {{ end }}{{if eq "app" .commonLabels._aliyun_arms_involvedObject_kind }} 应用名称:{{ .commonLabels._aliyun_arms_involvedObject_name }} {{ end }} 通知策略:{{ .dispatchRuleName }} 恢复时间:{{ .endTime }} 告警内容:{{ for .alerts }} {{ .annotations.message }} {{ end }} |
| TtsContent |
string |
电话告警通知内容。 |
告警名称:{{ .commonLabels.alertname }}{{if .commonLabels.clustername }} 集群名称:{{ .commonLabels.clustername }} {{ end }}{{if eq "app" .commonLabels._aliyun_arms_involvedObject_kind }} 应用名称:{{ .commonLabels._aliyun_arms_involvedObject_name }} {{ end }} 通知策略:{{ .dispatchRuleName }} 告警时间:{{ .startTime }} 告警内容:{{ for .alerts }} {{ .annotations.message }} {{ end }} |
| TtsRecoverContent |
string |
电话告警恢复通知内容。 |
告警名称:{{ .commonLabels.alertname }}{{if .commonLabels.clustername }} 集群名称:{{ .commonLabels.clustername }} {{ end }}{{if eq "app" .commonLabels._aliyun_arms_involvedObject_kind }} 应用名称:{{ .commonLabels._aliyun_arms_involvedObject_name }} {{ end }} 通知策略:{{ .dispatchRuleName }} 恢复时间:{{ .endTime }} 告警内容:{{ for .alerts }} {{ .annotations.message }} {{ end }} |
| RobotContent |
string |
机器人告警通知内容。 |
{{if .commonLabels.clustername }} > 集群名称:{{ .commonLabels.clustername }} {{ end }}{{if eq "app" .commonLabels._aliyun_arms_involvedObject_kind }} > 应用名称:{{ .commonLabels._aliyun_arms_involvedObject_name }} {{ end }}{{ for .alerts }} > {{ .annotations.message }} {{if .generatorURL }} [详情链接]({{.generatorURL}}) {{end}} {{if eq "true" .labels._aliyun_arms_is_denoise_filtered }} (疑似噪音) {{end}} {{end}} |
| EscalationPolicyId |
integer |
升级规则 ID。 |
123 |
| Repeat |
boolean |
对于长期未解决的告警是否发送重复通知。
|
true |
| RepeatInterval |
integer |
重复通知时间间隔,单位为秒。 |
600 |
| IntegrationId |
integer |
告警需要推送到的工单系统,显示为工单系统的集成 ID。 |
34 |
| DirectedMode |
boolean |
极简模式 |
|
| State |
string |
通知策略是否启用,enable 启用,disable 停用 |
enable |
示例
正常返回示例
JSON格式
{
"RequestId": "A5EC8221-08F2-4C95-9AF1-49FD998C****",
"NotificationPolicy": {
"Id": 1234,
"Name": "notificationpolicy_test",
"MatchingRules": [
{
"MatchingConditions": [
{
"Key": "altertname",
"Value": "test",
"Operator": "eq"
}
]
}
],
"SendRecoverMessage": true,
"GroupRule": {
"GroupingFields": [
"[\"alertName\",\"clustname\"]"
],
"GroupWait": 5,
"GroupInterval": 30
},
"NotifyRule": {
"NotifyStartTime": "00:00",
"NotifyEndTime": "23:59",
"NotifyChannels": [
"[\"dingTalk\", \"email\", \"sms\", \"tts\", \"webhook\"]"
],
"NotifyObjects": [
{
"NotifyObjectType": "CONTACT",
"NotifyObjectId": 123,
"NotifyObjectName": "test",
"NotifyChannels": [
"sms"
]
}
]
},
"NotifyTemplate": {
"EmailTitle": "{{ .commonLabels.alertname }}",
"EmailContent": "告警名称:{{ .commonLabels.alertname }}{{if .commonLabels.clustername }} 集群名称:{{ .commonLabels.clustername }} {{ end }}{{if eq \"app\" .commonLabels._aliyun_arms_involvedObject_kind }} 应用名称:{{ .commonLabels._aliyun_arms_involvedObject_name }} {{ end }} 通知策略:{{ .dispatchRuleName }} 告警时间:{{ .startTime }} 告警内容:{{ for .alerts }} {{ .annotations.message }} {{if .generatorURL }} 详情链接 {{ end }} {{ end }}",
"EmailRecoverTitle": "{{ .commonLabels.alertname }}",
"EmailRecoverContent": "告警名称:{{ .commonLabels.alertname }}{{if .commonLabels.clustername }} 集群名称:{{ .commonLabels.clustername }} {{ end }}{{if eq \"app\" .commonLabels._aliyun_arms_involvedObject_kind }} 应用名称:{{ .commonLabels._aliyun_arms_involvedObject_name }} {{ end }} 通知策略:{{ .dispatchRuleName }} 恢复时间:{{ .endTime }} 告警内容:{{ for .alerts }} {{ .annotations.message }} {{if .generatorURL }} 详情链接 {{ end }} {{ end }}",
"SmsContent": "发生{{ .level }}告警 告警名称:{{ .commonLabels.alertname }}{{if .commonLabels.clustername }} 集群名称:{{ .commonLabels.clustername }} {{ end }}{{if eq \"app\" .commonLabels._aliyun_arms_involvedObject_kind }} 应用名称:{{ .commonLabels._aliyun_arms_involvedObject_name }} {{ end }} 通知策略:{{ .dispatchRuleName }} 告警时间:{{ .startTime }} 告警内容:{{ for .alerts }} {{ .annotations.message }} {{ end }}",
"SmsRecoverContent": "告警已经恢复 告警名称:{{ .commonLabels.alertname }}{{if .commonLabels.clustername }} 集群名称:{{ .commonLabels.clustername }} {{ end }}{{if eq \"app\" .commonLabels._aliyun_arms_involvedObject_kind }} 应用名称:{{ .commonLabels._aliyun_arms_involvedObject_name }} {{ end }} 通知策略:{{ .dispatchRuleName }} 恢复时间:{{ .endTime }} 告警内容:{{ for .alerts }} {{ .annotations.message }} {{ end }}",
"TtsContent": "告警名称:{{ .commonLabels.alertname }}{{if .commonLabels.clustername }} 集群名称:{{ .commonLabels.clustername }} {{ end }}{{if eq \"app\" .commonLabels._aliyun_arms_involvedObject_kind }} 应用名称:{{ .commonLabels._aliyun_arms_involvedObject_name }} {{ end }} 通知策略:{{ .dispatchRuleName }} 告警时间:{{ .startTime }} 告警内容:{{ for .alerts }} {{ .annotations.message }} {{ end }}",
"TtsRecoverContent": "告警名称:{{ .commonLabels.alertname }}{{if .commonLabels.clustername }} 集群名称:{{ .commonLabels.clustername }} {{ end }}{{if eq \"app\" .commonLabels._aliyun_arms_involvedObject_kind }} 应用名称:{{ .commonLabels._aliyun_arms_involvedObject_name }} {{ end }} 通知策略:{{ .dispatchRuleName }} 恢复时间:{{ .endTime }} 告警内容:{{ for .alerts }} {{ .annotations.message }} {{ end }}",
"RobotContent": "{{if .commonLabels.clustername }} > 集群名称:{{ .commonLabels.clustername }} {{ end }}{{if eq \"app\" .commonLabels._aliyun_arms_involvedObject_kind }} > 应用名称:{{ .commonLabels._aliyun_arms_involvedObject_name }} {{ end }}{{ for .alerts }} > {{ .annotations.message }} {{if .generatorURL }} [详情链接]({{.generatorURL}}) {{end}} {{if eq \"true\" .labels._aliyun_arms_is_denoise_filtered }} (疑似噪音) {{end}} {{end}}"
},
"EscalationPolicyId": 123,
"Repeat": true,
"RepeatInterval": 600,
"IntegrationId": 34,
"DirectedMode": true,
"State": "enable"
}
}
错误码
访问错误中心查看更多错误码。
变更历史
更多信息,参考变更详情。