ActionTrail allows you to create an alert template to predefine or configure alert notifications in various formats. If specific conditions are met, ActionTrail sends alert notifications to the specified users or user groups based on the alert template that is used. This topic describes how to create, modify, and delete an alert template to meet alert requirements and information delivery specifications in different scenarios.
Create an alert template
By default, ActionTrail uses the SLS actiontrail builtin content template to send alert notifications to the specified users or user groups. You can also create a custom alert template based on your business requirements.
Log on to the ActionTrail console.
In the left-side navigation pane, click Alerts.
On the Alert Center page, choose .
Click Create.
In the Add Content Template dialog box, configure ID and Name.
Specify the notification content for each alert notification method.
Notification method
Description
SMS
You can configure the following parameters:
Language: the language of an alert notification. Valid values: Chinese and English.
Content: the content of an alert notification. You can enter content or use template variables to specify the content of an alert notification. For more information, see Variables in new alert templates.
Voice
You can configure the following parameters:
Language: the language of an alert notification. Valid values: Chinese and English.
Content: the content of an alert notification. You can enter content or use template variables to specify the content of an alert notification. For more information, see Variables in new alert templates.
Email
You can configure the following parameters:
Language: the language of an alert notification. Valid values: Chinese and English.
Subject: the subject of an alert notification. You can enter a subject or use template variables to specify the subject of an alert notification.
Content: the content of an alert notification. You can enter content or use template variables to specify the content of an alert notification. For more information, see Variables in new alert templates.
DingTalk
You can configure the following parameters:
Language: the language of an alert notification. Valid values: Chinese and English.
Disable Details Viewing: specifies whether to disable alert details viewing or alert rule management in logon-free mode. For more information, see View alert details in logon-free mode.
Title: the title of an alert notification. You can enter a title or use template variables to specify the title of an alert notification.
Content: the content of an alert notification. You can enter content or use template variables to specify the content of an alert notification. For more information, see Variables in new alert templates.
Webhook-Custom
You can configure the following parameters:
Sending Mode: the method that is used to send alert notifications. Valid values: Single and Batch.
For example, you enter
{ "project": "{{project}}", "alert_name": "{{alert_name}}"}in the Content field, and two alerts are triggered.Single: Two alert notifications are separately sent. The content is
{ "project": "project-1", "alert_name": "alert-1"}and{ "project": "project-2", "alert_name": "alert-2"}.Batch: Two alert notifications are sent at a time. The content is
[{ "project": "project-1", "alert_name": "alert-1"}, { "project": "project-2", "alert_name": "alert-2"}].If you select Batch and set the Maximum number of items sent in a group parameter to N, an alert notification for the first N alerts in a merge set is sent.
If you select Batch and the content that you specify can be parsed into JSON data, an alert notification is sent in the JSON format. If the content cannot be parsed into JSON data, an alert notification is sent as an array that contains strings.
Maximum number of items sent in a group: the maximum number of alerts that can be sent at a time. You can specify a custom value or select Unlimited.
Content: the content of an alert notification. You can enter content or use template variables to specify the content of an alert notification. For more information, see Variables in new alert templates.
NoteWhen ActionTrail sends alert notifications, the request header Content-Type: application/json;charset=utf-8 is used by default. If a webhook receiver requires a request header in a different format, you can specify a custom request header when you configure the notification method. For more information, see Notification methods.
Notifications
You can configure the following parameters:
Language: the language of an alert notification. Valid values: Chinese and English.
Content: the content of an alert notification. You can enter content or use template variables to specify the content of an alert notification. For more information, see Variables in new alert templates.
WeCom
You can configure the following parameters:
Language: the language of an alert notification. Valid values: Chinese and English.
Title: the title of an alert notification. You can enter a title or use template variables to specify the title of an alert notification.
Content: the content of an alert notification. You can enter content or use template variables to specify the content of an alert notification. For more information, see Variables in new alert templates.
Lark
You can configure the following parameters:
Language: the language of an alert notification. Valid values: Chinese and English.
Disable View Details: specifies whether to disable alert details viewing or alert rule management in logon-free mode. For more information, see View alert details in logon-free mode.
Title: the title of an alert notification. You can enter a title or use template variables to specify the title of an alert notification.
Content: the content of an alert notification. You can enter content or use template variables to specify the content of an alert notification. For more information, see Variables in new alert templates.
Slack
You can configure the following parameters:
Language: the language of an alert notification. Valid values: Chinese and English.
Title: the title of an alert notification. You can enter a title or use template variables to specify the title of an alert notification.
Content: the content of an alert notification. You can enter content or use template variables to specify the content of an alert notification. For more information, see Variables in new alert templates.
EventBridge
You can configure the following parameters:
Subject: the subject of an alert notification. You can enter a subject or use template variables to specify the subject of an alert notification.
Content: the content of an alert notification. You can enter content or use template variables to specify the content of an alert notification. For more information, see Variables in new alert templates.
Function Compute
You can configure the following parameters:
Sending Mode: the method that is used to send alert notifications. Valid values: Single and Batch.
For example, you enter
{ "project": "{{project}}", "alert_name": "{{alert_name}}"}in the Content field, and two alerts are triggered.Single: Two alert notifications are separately sent. The content is
{ "project": "project-1", "alert_name": "alert-1"}and{ "project": "project-2", "alert_name": "alert-2"}.Batch: Two alert notifications are sent at a time. The content is
[{ "project": "project-1", "alert_name": "alert-1"}, { "project": "project-2", "alert_name": "alert-2"}].If you select Batch and set the Maximum number of items sent in a group parameter to N, an alert notification for the first N alerts in a merge set is sent.
If you select Batch and the content that you specify can be parsed into JSON data, an alert notification is sent in the JSON format. If the content cannot be parsed into JSON data, an alert notification is sent as an array that contains strings.
Maximum number of items sent in a group: the maximum number of alerts that can be sent at a time. You can specify a custom value or select Unlimited.
Content: the content of an alert notification. You can enter content or use template variables to specify the content of an alert notification. For more information, see Variables in new alert templates.
Click Confirm.
Modify an alert template
Find the alert template that you want to modify and click Edit in the Actions column.
In the Edit Alert Template dialog box, change the name of the alert template, change alert notification methods that you want to use, or modify the notification content specified for alert notification methods.
Click Confirm.
Delete an alert template
Before you delete an alert template, make sure that the alert template is not referenced by action policies of alert rules. If you delete the alert template referenced by the action policy of an alert rule, ActionTrail uses the SLS actiontrail builtin content template to send alert notifications.
To prevent alert notification exceptions, do not delete the SLS actiontrail builtin content template.
Find the alert template that you want to delete and click Delete in the Actions column.
Click Confirm.
References
You can also configure alert templates in Simple Log Service. For more information, see Create an alert template.
You can also handle data based on the alert template syntax, which provides advanced custom rendering logic for alert notifications. For more information, see Syntax for new alert templates.
For more information about the built-in functions that are supported by alert templates, see Built-in functions in alert templates.