全部产品
Search
文档中心

应用实时监控服务ARMS:CreateOrUpdateNotificationPolicy - 新增及修改通知策略

更新时间:Aug 28, 2026

创建或更新通知策略。

调试

您可以在OpenAPI Explorer中直接运行该接口,免去您计算签名的困扰。运行成功后,OpenAPI Explorer可以自动生成SDK代码示例。

调试

授权信息

当前API暂无授权信息透出。

请求参数

名称

类型

必填

描述

示例值

Id

integer

否

通知策略 ID。

  • 不填代表创建新的通知策略。

  • 填写代表修改指定通知策略信息。

1234

Name

string

是

通知策略名称。

notificationpolicy_test

MatchingRules

string

否

匹配告警事件规则。格式如下:

[
 {
 "matchingConditions": [
 { 
 "value": "test",    //匹配告警事件规则 Value。
 "key": "alertname",     //匹配告警事件规则 Key。
 "operator": "eq"   //规则聚合方式,包括 eq(等于)、neq(不等于)、in(包含)、nin(不包含)、re(匹配正则)、nre(正则不匹配)。  
 }
 ]
 } 
 ]

[ { "matchingConditions": [ { "value": "test", "key": "alertname", "operator": "eq" } ] } ]

SendRecoverMessage

boolean

否

当告警下面全部事件都恢复时,告警状态是否自动恢复为已解决。当告警恢复时,系统将会发送通知给处理人。

  • true(默认):发送通知。

  • false:不发送通知。

true

GroupRule

string

否

设置事件分组。

  • 不填(默认):所有告警会按alertname分组发送给处理人。

  • 设置分组字段:相同字段的告警内容会分别通过独立信息发送给处理人。 分组格式如下:

{ 
"groupWait":5,    //分组等待时间。
"groupInterval":30,     //分组间隔时间。
"groupingFields":["alertname"]       //分组字段。
}

{ "groupWait":5, "groupInterval":30, "groupingFields":["alertname"] }

NotifyRule

string

是

设置通知规则。格式如下:

{ 
 "notifyStartTime":"00:00",      //通知时间段开始时间。
 "notifyEndTime":"23:59",       //通知时间段结束时间。
 "notifyChannels":["dingTalk", "email", "sms", "tts", "webhook"],       //通知方式,包括 dingTalk(钉钉)、email(邮件)、sms(短信)、tts(电话)和 webhook。
 "notifyObjects":[{       //通知对象。
 "notifyObjectType":"CONTACT",       //通知对象类型,包括 CONTACT(联系人)、CONTACT_GROUP(联系人组)、ARMS_CONTACT(ARMS 联系人)、ARMS_CONTACT_GROUP(ARMS 联系人组)、DING_ROBOT_GROUP(钉钉/飞书/企业微信 IM 机器人)、CONTACT_SCHEDULE(排班表)。
 "notifyObjectId":123,       //通知对象 ID。
 "notifyObjectName":"test"       //通知对象名称。
 "notifyChannels": [			//通知对象为联系人时单独指定的联系方式。包括 email(邮件)、sms(短信)、tts(电话)
                "email",		
                "sms",
                "tts"
            ],
 }]

{ "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(默认):设置为true后,必须设置 RepeatInterval。

  • false:设置为false后,必须设置 EscalationPolicyId。

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:等于

  • neq:不等于

  • in:包含

  • nin:不包含

  • re:匹配正则

  • nre:正则不匹配

eq

SendRecoverMessage

boolean

当告警下面全部事件都恢复时,告警状态是否自动恢复为已解决。当告警恢复时,系统将会发送通知给处理人。

  • true(默认):发送通知。

  • false:不发送通知。

true

GroupRule

object

事件分组。

GroupingFields

array

设置事件分组。

  • 不填(默认):所有告警会按alertname分组发送给处理人。

  • 设置分组字段:相同字段的告警内容会分别通过独立信息发送给处理人。

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:Webhook

["dingTalk", "email", "sms", "tts", "webhook"]

NotifyObjects

array<object>

通知对象列表。

object

通知对象

NotifyObjectType

string

通知对象类型。

  • CONTACT:联系人

  • CONTACT_GROUP:联系人组

  • ARMS_CONTACT:ARMS 联系人

  • ARMS_CONTACT_GROUP:ARMS 联系人组

  • DING_ROBOT_GROUP:钉钉/飞书/企业微信 IM 机器人

  • CONTACT_SCHEDULE:排班表

CONTACT

NotifyObjectId

integer

通知对象 ID。

123

NotifyObjectName

string

通知对象名称。

test

NotifyChannels

array

通知对象为联系人时的单独的联系方式

string

通知方式。

  • email:邮件

  • sms:短信

  • tts:电话

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(默认):按设置的重复通知时间间隔发送通知。

  • false:根据设置升级策略发送通知。

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

错误码

访问错误中心查看更多错误码。

变更历史

更多信息,参考变更详情。