Creates or modifies a notification policy.
Debugging
Authorization information
The following table shows the authorization information corresponding to the API. The authorization information can be used in the Action
policy element to grant a RAM user or RAM role the permissions to call this API operation. Description:
- Operation: the value that you can use in the Action element to specify the operation on a resource.
- Access level: the access level of each operation. The levels are read, write, and list.
- Resource type: the type of the resource on which you can authorize the RAM user or the RAM role to perform the operation. Take note of the following items:
- The required resource types are displayed in bold characters.
- If the permissions cannot be granted at the resource level,
All Resources
is used in the Resource type column of the operation.
- Condition Key: the condition key that is defined by the cloud service.
- Associated operation: other operations that the RAM user or the RAM role must have permissions to perform to complete the operation. To complete the operation, the RAM user or the RAM role must have the permissions to perform the associated operations.
Operation | Access level | Resource type | Condition key | Associated operation |
---|---|---|---|---|
arms:CreateDispatchRule | Write |
|
| none |
Request parameters
Parameter | Type | Required | Description | Example |
---|---|---|---|---|
Id | long | No | The ID of the notification policy.
| 1234 |
Name | string | Yes | The name of the notification policy. | notificationpolicy_test |
MatchingRules | string | No | The matching rules. Sample statement:
| [ { "matchingConditions": [ { "value": "test", "key": "alertname", "operator": "eq" } ] } ] |
SendRecoverMessage | boolean | No | Indicates whether the system sends a notification to the contacts when the status of an alert changes to Resolved. Default value: true. Valid values:
| true |
GroupRule | string | No | An array of alert event group objects.
| { "groupWait":5, "groupInterval":30, "groupingFields":["alertname"] } |
NotifyRule | string | Yes | An array of notification rule objects. Format:
| { "notifyStartTime":"00:00", "notifyEndTime":"23:59", "notifyChannels":[ "dingTalk", "email", "sms", "tts", "webhook" ], "notifyObjects":[ { "notifyObjectType":"CONTACT", "notifyObjectId":123, "notifyObjectName":"test" } ] } |
NotifyTemplate | string | No | The notification template. The default notification template is provided below the table. | {{if .commonLabels.clustername }} > Cluster Name: {{ .commonLabels.clustername }} {{ end }}{{if eq "app" .commonLabels._aliyun_arms_involvedObject_kind }} > App Name: {{ .commonLabels._aliyun_arms_involvedObject_name }} {{ end }}{{ for .alerts }} > {{ .annotations.message }} {{if .generatorURL }} [Details]({{.generatorURL}}) {{end}} {{if .annotations._aliyun_arms_insights_analyze_link }}[<font color='#ff0000'>diagnostic analysis</font>]({{ .annotations._aliyun_arms_insights_analyze_link}}){{ end }}{{if eq "1" .labels._aliyun_arms_denoise_code }} (Important:{{.labels._aliyun_arms_important_reason }}) {{end}} {{end}} |
EscalationPolicyId | long | No | The ID of the escalation policy. | 123 |
Repeat | boolean | No | Specifies whether to resend a notification for a long-lasting unresolved alert. Default value: true. Valid values:
| true |
RepeatInterval | long | No | The time interval at which a notification is resent for a long-lasting unresolved alert. Unit: seconds. | 600 |
IntegrationId | long | No | The integration ID of the ticket system to which alerts are pushed. | 34 |
RegionId | string | No | The ID of the region. | cn-hangzhou |
DirectedMode | boolean | No | Specifies whether to enable simple mode. |
Default notification template specified by the NotifyTemplate field
{
// An alert notification sent through email
"emailTitle":"{{ .commonLabels.alertname }}",
"emailContent":"Alert name: {{ .commonLabels.alertname }}{{if .commonLabels.clustername }} Cluster name: {{ .commonLabels.clustername }} {{ end }}{{if eq "app" .commonLabels._aliyun_arms_involvedObject_kind }} Application name: {{ .commonLabels._aliyun_arms_involvedObject_name }} {{ end }} Notification policy: {{ .dispatchRuleName }} Alert time: {{ .startTime }} Alert content: {{ for .alerts }} {{.annotations.message}} {{if .generatorURL }} <a href="{{.generatorURL}}" >Link</a> {{ end }} {{ end }}",
// An alert resolution notification sent through email
"emailRecoverTitle":"{{ .commonLabels.alertname }}",
"emailRecoverContent":"Alert name: {{ .commonLabels.alertname }}{{if .commonLabels.clustername }} Cluster name: {{ .commonLabels.clustername }} {{ end }}{{if eq "app" .commonLabels._aliyun_arms_involvedObject_kind }} Application name: {{ .commonLabels._aliyun_arms_involvedObject_name }} {{ end }} Notification policy: {{ .dispatchRuleName }} Alert resolution time: {{ .endTime }} Alert content: {{ for .alerts }} {{.annotations.message}} {{if .generatorURL }} <a href="{{.generatorURL}}" >Link</a> {{ end }} {{ end }}",
// An alert notification sent through text message
"smsContent":"Notification on the occurrence of a {{ .level }} alert. Alert name: {{ .commonLabels.alertname }}{{if .commonLabels.clustername }} Cluster name: {{ .commonLabels.clustername }} {{ end }}{{if eq "app" .commonLabels._aliyun_arms_involvedObject_kind }} Application name: {{ .commonLabels._aliyun_arms_involvedObject_name }} {{ end }} Notification policy: {{ .dispatchRuleName }} Alert time: {{ .startTime }} Alert content: {{ for .alerts }} {{.annotations.message}} {{ end }}}}",
// An alert resolution notification sent through text message
"smsRecoverContent":"Alert resolution notification. Alert name: {{ .commonLabels.alertname }}{{if .commonLabels.clustername }} Cluster name: {{ .commonLabels.clustername }} {{ end }}{{if eq "app" .commonLabels._aliyun_arms_involvedObject_kind }} Application name: {{ .commonLabels._aliyun_arms_involvedObject_name }} {{ end }} Notification policy: {{ .dispatchRuleName }} Alert resolution time: {{ .endTime }} Alert content: {{ for .alerts }} {{.annotations.message}} {{ end }}",
// An alert notification by phone
"tsContent":"Alert name: {{ .commonLabels.alertname }}{{if .commonLabels.clustername }} Cluster name: {{ .commonLabels.clustername }} {{ end }}{{if eq "app" .commonLabels._aliyun_arms_involvedObject_kind }} Application name: {{ .commonLabels._aliyun_arms_involvedObject_name }} {{ end }} Notification policy: {{ .dispatchRuleName }} Alert time: {{ .startTime }} Alert content: {{ for .alerts }} {{.annotations.message}} {{ end }}",
// An alert resolution notification by phone
"ttsRecoverContent":"Alert name: {{ .commonLabels.alertname }}{{if .commonLabels.clustername }} Cluster name: {{ .commonLabels.clustername }} {{ end }}{{if eq "app" .commonLabels._aliyun_arms_involvedObject_kind }} Application name: {{ .commonLabels._aliyun_arms_involvedObject_name }} {{ end }} Notification policy: {{ .dispatchRuleName }} Alert resolution time: {{ .endTime }} Alert content: {{ for .alerts }} {{.annotations.message}} {{ end }}",
// An alert notification sent by the instant message (IM) robot
"robotContent":"{{if .commonLabels.clustername }} > Cluster name: {{ .commonLabels.clustername }} {{ end }}{{if eq "app" .commonLabels._aliyun_arms_involvedObject_kind }} > Application name: {{ .commonLabels._aliyun_arms_involvedObject_name }} {{ end }}{{ for .alerts }} > {{.annotations.message}} {{if .generatorURL }} [Link]({{.generatorURL}}) {{ end }} {{if eq "true" .labels._aliyun_arms_is_denoise_filtered }} (Suspected noise) {{end}} {{end}}"
}
Response parameters
//Email Content
{{ .commonLabels.alertname }}
Alert Name: {{ .commonLabels.alertname }}{{if .commonLabels.clustername }}
Cluster Name: {{ .commonLabels.clustername }} {{ end }}{{if eq "app" .commonLabels._aliyun_arms_involvedObject_kind }}
App Name: {{ .commonLabels._aliyun_arms_involvedObject_name }} {{ end }}
Notification Policy: {{ .dispatchRuleName }}
Alert Time: {{ .startTime }}
Description: {{ for .alerts }} {{ .annotations.message }} {{if .generatorURL }} <a href="{{.generatorURL}}" > Details</a>
{{ end }} {{ end }}
//Email Recover Content
{{ .commonLabels.alertname }}
Alert Name: {{ .commonLabels.alertname }}{{if .commonLabels.clustername }}
Cluster Name: {{ .commonLabels.clustername }} {{ end }}{{if eq "app" .commonLabels._aliyun_arms_involvedObject_kind }}
App Name: {{ .commonLabels._aliyun_arms_involvedObject_name }} {{ end }}
Notification Policy: {{ .dispatchRuleName }}
Recover Time: {{ .endTime }}
Description: {{ for .alerts }} {{ .annotations.message }} {{if .generatorURL }} <a href="{{.generatorURL}}" > Details</a>
{{ end }} {{ end }}
//Sms Content
{{ .level }}Alert Occurs
Alert Name: {{ .commonLabels.alertname }}{{if .commonLabels.clustername }}
Cluster Name: {{ .commonLabels.clustername }} {{ end }}{{if eq "app" .commonLabels._aliyun_arms_involvedObject_kind }}
App Name: {{ .commonLabels._aliyun_arms_involvedObject_name }} {{ end }}
Notification Policy: {{ .dispatchRuleName }}
Alert Time: {{ .startTime }}
Description: {{ for .alerts }} {{ .annotations.message }} {{ end }}
//Sms RecoverContent
Alert Recovery Notification
Alert Name: {{ .commonLabels.alertname }}{{if .commonLabels.clustername }}
Cluster Name: {{ .commonLabels.clustername }} {{ end }}{{if eq "app" .commonLabels._aliyun_arms_involvedObject_kind }}
App Name: {{ .commonLabels._aliyun_arms_involvedObject_name }} {{ end }}
Notification Policy: {{ .dispatchRuleName }}
Recover Time: {{ .endTime }}
Description: {{ for .alerts }} {{ .annotations.message }} {{ end }}
//Tts Content
Alert Name: {{ .commonLabels.alertname }}{{if .commonLabels.clustername }}
Cluster Name: {{ .commonLabels.clustername }} {{ end }}{{if eq "app" .commonLabels._aliyun_arms_involvedObject_kind }}
App Name: {{ .commonLabels._aliyun_arms_involvedObject_name }} {{ end }}
Notification Policy: {{ .dispatchRuleName }}
Alert Time: {{ .startTime }}
Description: {{ for .alerts }} {{ .annotations.message }} {{ end }}
//Tts RecoverContent
Alert Name: {{ .commonLabels.alertname }}{{if .commonLabels.clustername }}
Cluster Name: {{ .commonLabels.clustername }} {{ end }}{{if eq "app" .commonLabels._aliyun_arms_involvedObject_kind }}
App Name: {{ .commonLabels._aliyun_arms_involvedObject_name }} {{ end }}
Notification Policy: {{ .dispatchRuleName }}
Recover Time: {{ .endTime }}
Description: {{ for .alerts }} {{ .annotations.message }} {{ end }}
//RobotContent
{{if .commonLabels.clustername }}
> Cluster Name: {{ .commonLabels.clustername }}
{{ end }}{{if eq "app" .commonLabels._aliyun_arms_involvedObject_kind }}
> App Name: {{ .commonLabels._aliyun_arms_involvedObject_name }}
{{ end }}{{ for .alerts }} > {{ .annotations.message }} {{if .generatorURL }} [Details]({{.generatorURL}}) {{end}} {{if .annotations._aliyun_arms_insights_analyze_link }}[<font color='#ff0000'>diagnostic analysis</font>]({{ .annotations._aliyun_arms_insights_analyze_link}}){{ end }}{{if eq "1" .labels._aliyun_arms_denoise_code }} (Important:{{.labels._aliyun_arms_important_reason }}) {{end}}
{{end}}
Examples
Sample success responses
JSON
format
{
"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": [
""
]
}
]
},
"NotifyTemplate": {
"EmailTitle": "{{ .commonLabels.alertname }}",
"EmailContent": "Alert Name: {{ .commonLabels.alertname }}{{if .commonLabels.clustername }}\nCluster Name: {{ .commonLabels.clustername }} {{ end }}{{if eq \"app\" .commonLabels._aliyun_arms_involvedObject_kind }}\nApp Name: {{ .commonLabels._aliyun_arms_involvedObject_name }} {{ end }}\nNotification Policy: {{ .dispatchRuleName }}\nAlert Time: {{ .startTime }}\nDescription: {{ for .alerts }} {{ .annotations.message }} {{if .generatorURL }} <a href=\"{{.generatorURL}}\" > Details</a>\n {{ end }} {{ end }}",
"EmailRecoverTitle": "{{ .commonLabels.alertname }}",
"EmailRecoverContent": "Alert Name: {{ .commonLabels.alertname }}{{if .commonLabels.clustername }}\nCluster Name: {{ .commonLabels.clustername }} {{ end }}{{if eq \"app\" .commonLabels._aliyun_arms_involvedObject_kind }}\nApp Name: {{ .commonLabels._aliyun_arms_involvedObject_name }} {{ end }}\nNotification Policy: {{ .dispatchRuleName }}\nRecover Time: {{ .endTime }}\nDescription: {{ for .alerts }} {{ .annotations.message }} {{if .generatorURL }} <a href=\"{{.generatorURL}}\" > Details</a>\n {{ end }} {{ end }}",
"SmsContent": "{{ .level }}Alert Occurs\nAlert Name: {{ .commonLabels.alertname }}{{if .commonLabels.clustername }}\nCluster Name: {{ .commonLabels.clustername }} {{ end }}{{if eq \"app\" .commonLabels._aliyun_arms_involvedObject_kind }}\nApp Name: {{ .commonLabels._aliyun_arms_involvedObject_name }} {{ end }}\nNotification Policy: {{ .dispatchRuleName }}\nAlert Time: {{ .startTime }}\nDescription: {{ for .alerts }} {{ .annotations.message }} {{ end }}",
"SmsRecoverContent": "Alert Recovery Notification\nAlert Name: {{ .commonLabels.alertname }}{{if .commonLabels.clustername }}\nCluster Name: {{ .commonLabels.clustername }} {{ end }}{{if eq \"app\" .commonLabels._aliyun_arms_involvedObject_kind }}\nApp Name: {{ .commonLabels._aliyun_arms_involvedObject_name }} {{ end }}\nNotification Policy: {{ .dispatchRuleName }}\nRecover Time: {{ .endTime }}\nDescription: {{ for .alerts }} {{ .annotations.message }} {{ end }}",
"TtsContent": "Alert Name: {{ .commonLabels.alertname }}{{if .commonLabels.clustername }}\nCluster Name: {{ .commonLabels.clustername }} {{ end }}{{if eq \"app\" .commonLabels._aliyun_arms_involvedObject_kind }}\nApp Name: {{ .commonLabels._aliyun_arms_involvedObject_name }} {{ end }}\nNotification Policy: {{ .dispatchRuleName }}\nAlert Time: {{ .startTime }}\nDescription: {{ for .alerts }} {{ .annotations.message }} {{ end }}",
"TtsRecoverContent": "Alert Name: {{ .commonLabels.alertname }}{{if .commonLabels.clustername }}\nCluster Name: {{ .commonLabels.clustername }} {{ end }}{{if eq \"app\" .commonLabels._aliyun_arms_involvedObject_kind }}\nApp Name: {{ .commonLabels._aliyun_arms_involvedObject_name }} {{ end }}\nNotification Policy: {{ .dispatchRuleName }}\nRecover Time: {{ .endTime }}\nDescription: {{ for .alerts }} {{ .annotations.message }} {{ end }}",
"RobotContent": "{{if .commonLabels.clustername }}\n\n > Cluster Name: {{ .commonLabels.clustername }} \n\n {{ end }}{{if eq \"app\" .commonLabels._aliyun_arms_involvedObject_kind }}\n\n > App Name: {{ .commonLabels._aliyun_arms_involvedObject_name }} \n\n {{ end }}{{ for .alerts }} > {{ .annotations.message }} {{if .generatorURL }} [Details]({{.generatorURL}}) {{end}} {{if .annotations._aliyun_arms_insights_analyze_link }}[<font color='#ff0000'>diagnostic analysis</font>]({{ .annotations._aliyun_arms_insights_analyze_link}}){{ end }}{{if eq \"1\" .labels._aliyun_arms_denoise_code }} (Important:{{.labels._aliyun_arms_important_reason }}) {{end}}\n\n{{end}}"
},
"EscalationPolicyId": 123,
"Repeat": true,
"RepeatInterval": 600,
"IntegrationId": 34,
"DirectedMode": true
}
}
Error codes
For a list of error codes, visit the Service error codes.
Change history
Change time | Summary of changes | Operation | ||||||
---|---|---|---|---|---|---|---|---|
2023-08-17 | The request parameters of the API has changed. The response structure of the API has changed | see changesets | ||||||
| ||||||||
2023-03-30 | The response structure of the API has changed | see changesets | ||||||
| ||||||||
2022-02-24 | Add Operation | see changesets |