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 | none |
|
| 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. Format:
| [ { "matchingConditions": [ { "value": "test", "key": "alertname", "operator": "eq" } ] } ] |
SendRecoverMessage | boolean | No | Specifies whether the status of an alert automatically changes to Resolved when all events related to the alert change to the Restored state. ARMS notifies contacts when the alert status changes to Resolved.
| true |
GroupRule | string | No | An array of alert event group objects.
Sample statement:
| { "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. | "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}}" |
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. | false |
State | string | No | Specifies whether to enable the notification policy. Valid values: enable and disable. | enable |
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
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": [
"sms\n"
]
}
]
},
"NotifyTemplate": {
"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}}\n",
"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}}\n",
"SmsContent": "\\<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 }}\\</SmsContent>\n",
"SmsRecoverContent": "\\<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 }}\\</SmsRecoverContent>\n",
"TtsContent": "\\<TtsContent>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 }}\\</TtsContent>\n",
"TtsRecoverContent": "\\<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 }}\\</TtsRecoverContent>\n",
"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}}\n"
},
"EscalationPolicyId": 123,
"Repeat": true,
"RepeatInterval": 600,
"IntegrationId": 34,
"DirectedMode": false,
"State": "enable"
}
}
Error codes
For a list of error codes, visit the Service error codes.
Change history
Change time | Summary of changes | Operation |
---|---|---|
2024-06-19 | The request parameters of the API has changed. The response structure of the API has changed | View Change Details |
2023-08-17 | The request parameters of the API has changed. The response structure of the API has changed | View Change Details |
2023-03-30 | The response structure of the API has changed | View Change Details |
2022-02-24 | Add Operation | View Change Details |