All Products
Search
Document Center

Application Real-Time Monitoring Service:CreateOrUpdateNotificationPolicy

Last Updated:Nov 05, 2024

Creates or modifies a notification policy.

Debugging

You can run this interface directly in OpenAPI Explorer, saving you the trouble of calculating signatures. After running successfully, OpenAPI Explorer can automatically generate SDK code samples.

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.
OperationAccess levelResource typeCondition keyAssociated operation
arms:CreateDispatchRulenone
  • All Resources
    *
    none
none

Request parameters

ParameterTypeRequiredDescriptionExample
IdlongNo

The ID of the notification policy.

  • If you do not specify this parameter, a new notification policy is created.
  • If you specify this parameter, the specified notification policy is modified.
1234
NamestringYes

The name of the notification policy.

notificationpolicy_test
MatchingRulesstringNo

The matching rules. Format:

[
 {
 "matchingConditions": [
 { 
 "value": "test",    // The value of the matching condition. 
 "key": "alertname",     // The key of the matching condition. 
 "operator": "eq"   // The logical operator of the matching condition, including eq (equal to), neq (not equal to), in (contains), nin (does not contain), re (regular expression match), and nre (regular expression mismatch).   
 }
 ]
 } 
 ]
[ { "matchingConditions": [ { "value": "test", "key": "alertname", "operator": "eq" } ] } ]
SendRecoverMessagebooleanNo

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: The system sends a notification.
  • false: The system does not send a notification.
true
GroupRulestringNo

An array of alert event group objects.

  • If you do not specify the groupingFields field, all alerts will be sent to contacts based on alertname.
  • If you specify the groupingFields field, alerts with the same field will be sent to contacts in one notification.

Sample statement:

{ 
"groupWait":5,    // The waiting time for grouping. 
"groupInterval":30,     // The time interval of grouping. 
"groupingFields":["alertname"]       // The field that is used to group alert events. 
}
{ "groupWait":5, "groupInterval":30, "groupingFields":["alertname"] }
NotifyRulestringYes

An array of notification rule objects. Format:

{ 
 "notifyStartTime":"00:00",      // The start time of the notification window. 
 "notifyEndTime":"23:59",       // The end time of the notification window. 
 "notifyChannels":["dingTalk", "email", "sms", "tts", "webhook"],       // The notification methods. Valid values: dingTalk, email, sms, tts, and webhook. 
 "notifyObjects":[{       // An array of notification objects. 
 "notifyObjectType":"CONTACT",       // The type of the notification object. Valid values: CONTACT (contact), CONTACT_GROUP (contact group), ARMS_CONTACT (ARMS contact), ARMS_CONTACT_GROUP (ARMS contact group), DING_ROBOT_GROUP (DingTalk, Lark, WeCom, or IM robot), and CONTACT_SCHEDULE (user on duty defined by a schedule). 
 "notifyObjectId":123,       // The ID of the notification object. 
 "notifyObjectName":"test"       // The name of the notification object. 
 }]
{ "notifyStartTime":"00:00", "notifyEndTime":"23:59", "notifyChannels":[ "dingTalk", "email", "sms", "tts", "webhook" ], "notifyObjects":[ { "notifyObjectType":"CONTACT", "notifyObjectId":123, "notifyObjectName":"test" } ] }
NotifyTemplatestringNo

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}}"
EscalationPolicyIdlongNo

The ID of the escalation policy.

123
RepeatbooleanNo

Specifies whether to resend a notification for a long-lasting unresolved alert. Default value: true. Valid values:

  • true: If you set this parameter to true, you must set RepeatInterval.
  • false: If you set this parameter to false, you must set EscalationPolicyId.
true
RepeatIntervallongNo

The time interval at which a notification is resent for a long-lasting unresolved alert. Unit: seconds.

600
IntegrationIdlongNo

The integration ID of the ticket system to which alerts are pushed.

34
RegionIdstringNo

The ID of the region.

cn-hangzhou
DirectedModebooleanNo

Specifies whether to enable simple mode.

false
StatestringNo

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

ParameterTypeDescriptionExample
object

Schema of Response

RequestIdstring

The ID of the request.

A5EC8221-08F2-4C95-9AF1-49FD998C****
NotificationPolicyobject

An array of notification policy objects.

Idlong

The ID of the notification policy.

1234
Namestring

The name of the notification policy.

notificationpolicy_test
MatchingRulesarray<object>

The matching rules.

matchingRulesobject
MatchingConditionsarray<object>

The matching conditions.

matchingConditionsobject
Keystring

The key of the matching condition.

altertname
Valuestring

The value of the matching condition.

test
Operatorstring

The logical operator of the matching condition. Valid values:

  • eq: equal to
  • neq: not equal to
  • in: contains
  • nin: does not contain
  • re: regular expression match
  • nre: regular expression mismatch
eq
SendRecoverMessageboolean

Indicates 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: The system sends a notification.
  • false: The system does not send a notification.
true
GroupRuleobject

An array of alert event group objects.

GroupingFieldsarray

An array of alert event group objects.

  • If you do not specify the groupingFields field, all alerts will be sent to contacts based on alertname.
  • If you specify the groupingFields field, alerts with the same field will be sent to contacts in one notification.
groupingFieldsstring

The field that is used for grouping.

["alertName","clustname"]
GroupWaitlong

The waiting time for grouping. Unit: seconds. Default value: 5.

5
GroupIntervallong

The time interval of grouping. Unit: seconds. Default value: 30.

30
NotifyRuleobject

An array of notification rule objects.

NotifyStartTimestring

The start time of the notification window.

00:00
NotifyEndTimestring

The end time of the notification window.

23:59
NotifyChannelsarray

The notification method.

notifyChannelsstring

The notification methods. Valid values:

  • dingTalk: DingTalk
  • email: email
  • sms: text message
  • tts: phone call
  • webhook: webhook
["dingTalk", "email", "sms", "tts", "webhook"]
NotifyObjectsarray<object>

An array of notification objects.

notifyObjectsobject

The information about the notification object.

NotifyObjectTypestring

The type of the notification object. Valid values:

  • CONTACT: contact
  • CONTACT_GROUP: contact group
  • ARMS_CONTACT: ARMS contact
  • ARMS_CONTACT_GROUP: ARMS contact group
  • DING_ROBOT_GROUP: DingTalk, Lark, WeCom, or IM robot
  • CONTACT_SCHEDULE: user on duty defined by a schedule
CONTACT
NotifyObjectIdlong

The ID of the notification object.

123
NotifyObjectNamestring

The name of the notification object.

test
NotifyChannelsarray

The notification methods specified for a contact.

notifyChannelsstring

The notification methods. Valid values:

  • email: email
  • sms: text message
  • tts: phone call
sms
NotifyTemplateobject

The notification template.

EmailTitlestring

The title of the alert notification sent through email.

{{ .commonLabels.alertname }}
EmailContentstring

The content of the alert notification sent through email.

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}}
EmailRecoverTitlestring

The title of the alert resolution notification sent through email.

{{ .commonLabels.alertname }}
EmailRecoverContentstring

The content of the alert resolution notification sent through email.

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}}
SmsContentstring

The content of the 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 }}\</SmsContent>
SmsRecoverContentstring

The content of the 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 }}\</SmsRecoverContent>
TtsContentstring

The content of the alert notification by phone.

\<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>
TtsRecoverContentstring

The content of the 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 }}\</TtsRecoverContent>
RobotContentstring

The content of the alert notification sent by the IM robot.

{{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}}
EscalationPolicyIdlong

The ID of the escalation policy.

123
Repeatboolean

Indicates whether a notification is resent for a long-lasting unresolved alert. Default value: true. Valid values:

  • true: The system resends a notification for a long-lasting unresolved alert at a specified time interval.
  • false: The system sends a notification for a long-lasting unresolved alert based on an escalation policy.
true
RepeatIntervallong

The time interval at which a notification is resent for a long-lasting unresolved alert. Unit: seconds.

600
IntegrationIdlong

The integration ID of the ticket system to which alerts are pushed.

34
DirectedModeboolean

Specifies whether to enable simple mode.

false
Statestring

Indicates whether the notification policy is enabled. Valid values: enable and disable.

enable

Examples

Sample success responses

JSONformat

{
  "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 timeSummary of changesOperation
2024-06-19The request parameters of the API has changed. The response structure of the API has changedView Change Details
2023-08-17The request parameters of the API has changed. The response structure of the API has changedView Change Details
2023-03-30The response structure of the API has changedView Change Details
2022-02-24Add OperationView Change Details