All Products
Search
Document Center

Application Real-Time Monitoring Service:CreateOrUpdateNotificationPolicy

Last Updated:Jun 12, 2026

Buat atau perbarui kebijakan notifikasi.

Coba sekarang

Coba API ini di OpenAPI Explorer tanpa perlu penandatanganan manual. Panggilan yang berhasil akan secara otomatis menghasilkan contoh kode SDK sesuai dengan parameter Anda. Unduh kode tersebut dengan kredensial bawaan yang aman untuk penggunaan lokal.

Test

RAM authorization

Tidak ada otorisasi untuk operasi ini. Jika Anda mengalami masalah saat menjalankan operasi ini, hubungi dukungan teknis.

Parameter permintaan

Parameter

Type

Required

Description

Example

Id

integer

No

ID kebijakan notifikasi.

  • Kosongkan untuk membuat kebijakan notifikasi baru.

  • Tentukan nilai untuk mengubah informasi kebijakan notifikasi yang ditentukan.

1234

Name

string

Yes

Nama kebijakan notifikasi.

notificationpolicy_test

MatchingRules

string

No

Aturan yang digunakan untuk mencocokkan peristiwa peringatan. Formatnya adalah sebagai berikut:

[
 {
 "matchingConditions": [
 { 
 "value": "test",    //Value aturan pencocokan peristiwa peringatan.
 "key": "alertname",     //Key aturan pencocokan peristiwa peringatan.
 "operator": "eq"   //Metode agregasi aturan. Nilai yang valid: eq (sama dengan), neq (tidak sama dengan), in (berisi), nin (tidak berisi), re (cocok dengan ekspresi reguler), nre (tidak cocok dengan ekspresi reguler).  
 }
 ]
 } 
 ]

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

SendRecoverMessage

boolean

No

Menentukan apakah status peringatan secara otomatis dipulihkan ke Resolved ketika semua peristiwa di bawah peringatan tersebut dipulihkan. Ketika peringatan dipulihkan, sistem mengirim notifikasi kepada penanggung jawab.

  • true (default): mengirim notifikasi.

  • false: tidak mengirim notifikasi.

true

GroupRule

string

No

Mengatur pengelompokan peristiwa.

  • Kosong (default): semua peringatan dikelompokkan berdasarkan alertname dan dikirim kepada penanggung jawab.

  • Tentukan field pengelompokan: konten peringatan dengan field yang sama dikirim kepada penanggung jawab melalui pesan terpisah. Format pengelompokannya adalah sebagai berikut:

{ 
"groupWait":5,    //Waktu tunggu grup.
"groupInterval":30,     //Interval grup.
"groupingFields":["alertname"]       //Field pengelompokan.
}

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

NotifyRule

string

Yes

Mengatur aturan notifikasi. Formatnya adalah sebagai berikut:

{ 
 "notifyStartTime":"00:00",      //Waktu mulai periode waktu notifikasi.
 "notifyEndTime":"23:59",       //Waktu berakhir periode waktu notifikasi.
 "notifyChannels":["dingTalk", "email", "sms", "tts", "webhook"],       //Metode notifikasi, termasuk dingTalk (DingTalk), email, sms (SMS), tts (telepon), dan webhook.
 "notifyObjects":[{       //Objek notifikasi.
 "notifyObjectType":"CONTACT",       //Tipe objek notifikasi. Nilai yang valid: CONTACT (kontak), CONTACT_GROUP (grup kontak), ARMS_CONTACT (kontak ARMS), ARMS_CONTACT_GROUP (grup kontak ARMS), DING_ROBOT_GROUP (robot IM DingTalk/Lark/WeCom), CONTACT_SCHEDULE (jadwal jaga).
 "notifyObjectId":123,       //ID objek notifikasi.
 "notifyObjectName":"test"       //Nama objek notifikasi.
 "notifyChannels": [			//Metode kontak yang ditentukan secara individual ketika objek notifikasi adalah kontak. Nilai yang valid: email, sms (SMS), tts (telepon).
                "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

No

Template notifikasi. Untuk contoh template, lihat deskripsi di bawah tabel.

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

No

ID kebijakan eskalasi.

123

Repeat

boolean

No

Menentukan apakah akan mengirim notifikasi berulang untuk peringatan yang belum diselesaikan dalam waktu yang lama.

  • true (default): jika diatur ke true, RepeatInterval harus ditentukan.

  • false: jika diatur ke false, EscalationPolicyId harus ditentukan.

true

RepeatInterval

integer

No

Interval notifikasi berulang, dalam detik.

600

IntegrationId

integer

No

Sistem tiket tempat peringatan akan dikirim. Masukkan ID integrasi sistem tiket.

34

RegionId

string

No

ID region.

cn-hangzhou

DirectedMode

boolean

No

Mode minimalis.

false

State

string

No

Apakah kebijakan notifikasi diaktifkan. Nilai yang valid: enable (diaktifkan), disable (dinonaktifkan).

enable

Contoh template notifikasi default NotifyTemplate

{
//Notifikasi peringatan email
"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 }}",

//Notifikasi pemulihan peringatan email
"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 }}",

//Notifikasi peringatan SMS
"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 }}",

//Notifikasi pemulihan peringatan SMS
"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 }}",

//Notifikasi peringatan telepon
"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 }}",

//Notifikasi pemulihan peringatan telepon
"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 }}",

//Notifikasi peringatan robot
"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}}"

}

Elemen respons

Element

Type

Description

Example

object

Skema Respons

RequestId

string

ID permintaan.

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

NotificationPolicy

object

Objek kebijakan notifikasi.

Id

integer

ID kebijakan notifikasi.

1234

Name

string

Nama kebijakan notifikasi.

notificationpolicy_test

MatchingRules

array<object>

Aturan yang digunakan untuk mencocokkan peristiwa peringatan.

array<object>

MatchingConditions

array<object>

The matching conditions.

object

Key

string

The key of the matching condition.

altertname

Value

string

The value of the matching condition.

test

Operator

string

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

SendRecoverMessage

boolean

Menentukan apakah status peringatan secara otomatis dipulihkan ke Resolved ketika semua peristiwa di bawah peringatan tersebut dipulihkan. Ketika peringatan dipulihkan, sistem mengirim notifikasi kepada penanggung jawab.

  • true (default): mengirim notifikasi.

  • false: tidak mengirim notifikasi.

true

GroupRule

object

Pengelompokan peristiwa.

GroupingFields

array

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.

string

The field that is used for grouping.

["alertName","clustname"]

GroupWait

integer

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

5

GroupInterval

integer

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

30

NotifyRule

object

Aturan notifikasi.

NotifyStartTime

string

The start time of the notification window.

00:00

NotifyEndTime

string

The end time of the notification window.

23:59

NotifyChannels

array

The notification method.

string

The notification methods. Valid values:

  • dingTalk: DingTalk

  • email: email

  • sms: text message

  • tts: phone call

  • webhook: webhook

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

NotifyObjects

array<object>

An array of notification objects.

object

The information about the notification object.

NotifyObjectType

string

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

NotifyObjectId

integer

The ID of the notification object.

123

NotifyObjectName

string

The name of the notification object.

test

NotifyChannels

array

The notification methods specified for a contact.

string

The notification methods. Valid values:

  • email: email

  • sms: text message

  • tts: phone call

sms

NotifyTemplate

object

Template notifikasi.

EmailTitle

string

The title of the alert notification sent through email.

{{ .commonLabels.alertname }}

EmailContent

string

The content of the alert notification sent through email.

告警名称:{{ .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

The title of the alert resolution notification sent through email.

{{ .commonLabels.alertname }}

EmailRecoverContent

string

The content of the alert resolution notification sent through email.

告警名称:{{ .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

The content of the alert notification sent through text message.

发生{{ .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

The content of the alert resolution notification sent through text message.

告警已经恢复 告警名称:{{ .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

The content of the alert notification by phone.

告警名称:{{ .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

The content of the alert resolution notification by phone.

告警名称:{{ .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

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

{{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 kebijakan eskalasi.

123

Repeat

boolean

Menentukan apakah akan mengirim notifikasi berulang untuk peringatan yang belum diselesaikan dalam waktu yang lama.

  • true (default): mengirim notifikasi berdasarkan interval notifikasi berulang yang dikonfigurasi.

  • false: mengirim notifikasi berdasarkan kebijakan eskalasi yang dikonfigurasi.

true

RepeatInterval

integer

Interval notifikasi berulang, dalam detik.

600

IntegrationId

integer

Sistem tiket tempat peringatan akan dikirim, ditampilkan sebagai ID integrasi sistem tiket.

34

DirectedMode

boolean

Mode minimalis.

State

string

Apakah kebijakan notifikasi diaktifkan. Nilai yang valid: enable (diaktifkan), disable (dinonaktifkan).

enable

Contoh

Respons sukses

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"
          ]
        }
      ]
    },
    "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": false,
    "State": "enable"
  }
}

Kode kesalahan

Lihat Error Codes untuk daftar lengkap.

Catatan rilis

Lihat Release Notes untuk daftar lengkap.