Define notification templates to deliver alerts through phone, SMS, email, DingTalk, WeCom, Lark, Slack, or webhooks. Templates support variables and bilingual (Chinese and English) content.
Create a notification template
The following example creates an email notification template.
-
Log on to the Cloud Monitor 2.0 console, select the target workspace, and in the left-side navigation pane, navigate to .
-
Click Create notification template.
-
In the Create/edit notification template panel, configure the parameters described in the following table.
Parameter
Description
Template name
Required. The template name. Use a descriptive name for easy identification.
Template ID
Required. A unique identifier. Cannot be modified after creation. Use letters, numbers, and underscores (_).
Type
Required. The delivery channel. Cannot be modified after creation. Valid values:
- Phone: Voice call notifications.
- SMS: Text message notifications.
- Email: HTML-formatted notifications. Requires a Notification title.
- DingTalk: DingTalk bot notifications. Supports Markdown.
- WeCom: WeCom bot notifications. Supports Markdown.
- Lark: Lark bot notifications. Supports Markdown.
- Slack: Slack bot notifications. Supports Markdown.
- webhook: Custom webhook notifications. Supports Markdown.
Notification content
Required. The message body. Supports variables. Configure both the Chinese template and the English template.
-
Click OK.
Delete a template
-
On the Notification template page, find the target template and click Delete in the Actions column.
-
In the confirmation dialog box, click OK.
This action cannot be undone. Notification policies that reference this template will fail to send notifications.
Template variables
Templates use Go template syntax. Insert variables in the format {{ .VariableName }} to populate alert data dynamically.
Subscription and incident variables
|
Parameter |
Description |
|
|
Notification policy name. |
|
|
Number of associated alert events. |
|
|
Highest severity across alert events. |
|
|
User ID. |
|
|
Grouping key-value pairs (Map object). |
Event detail variables
Iterate over .events to access each alert event:
|
Parameter |
Description |
|
|
Alert severity. |
|
|
Time the alert was triggered. |
|
|
Event type. |
|
|
Alert title. |
|
|
Alert labels. |
|
|
Alert annotations. |
|
|
Resource domain. |
|
|
Entity type. |
|
|
Entity ID. |
|
|
Resource properties. |
Template syntax examples
Iterate over grouping key-value pairs:
{{ range $key, $value := .incident.groupingKeys }} >> {{ $key }} = {{ $value }}
{{ end }}
Iterate over alert events (limit to the first 3):
{{ range $index, $event := .events }}
{{ if lt $index 3 }} >- Severity: {{ $event.severity }} >- Time: {{ $event.time }} >- Title: {{ $event.subject }}
{{ end }}
{{ end }}