You can create an alert notification template to customize the titles and content of alert notifications and alert resolution notifications.
Procedure
Log in to the OceanBase Cloud console.
In the left-side navigation pane, click Alerts.
On the Alert Management page, click More, and then click Notification templates.
On the Notification templates tab, click Create notification template.
Configure the alert notification template and click Create.
Notice
For security reasons, the alert notification template content must contain the keyword OBCloud or OceanBase.
ParameterDescriptionTemplate Name The name of the alert notification template. Notification Method The method to send alert notifications. Different notification methods support different notification formats. - Email: Specify the title and content of the alert notification template.
- DingTalk: Specify the title and content of the alert notification template.
- Lark: Text format. Specify the content of the alert notification template.
- Telegram: Text format. Specify the content of the alert notification template.
- Custom URL: The default template is in JSON format. You can modify the template to support the format specified by the custom URL. For more information, see the Custom URL Format Example section.
Alert Notification Template Title The title displayed in alert notifications. Specify it when you select email or DingTalk. Use placeholders such as ${AlertName}to insert variables.AlertNamerepresents the alert name.Note
The title can contain up to 50 characters, including variable values after substitution. Any excess is truncated.
Alert Notification Template Content The content displayed in an alert notification. You can preview the content and send a test notification in the panel on the right. Use placeholders such as ${AlertName}to insert variables.AlertNamerepresents the alert name. For more information about the supported variables, see Alert variables.Note
The content can contain up to 500 characters, including variable values after substitution. Any excess is truncated.
Alert Resolution Notification Template Title The title displayed in alert resolution notifications. Specify it when you select email or DingTalk. Use placeholders such as ${AlertName}to insert variables.AlertNamerepresents the alert name.Note
The title can contain up to 50 characters, including variable values after substitution. Any excess is truncated.
Alert Resolution Notification Template Content The content displayed in the alert resolution notification. You can preview the content and send a test notification in the panel on the right. Use placeholders such as ${AlertName}to insert variables.AlertNamerepresents the alert name. For more information about the supported variables, see Alert variables.Note
The content can contain up to 500 characters, including variable values after substitution. Any excess is truncated.
After the template is created, you can view and manage it in the list.
Alert variables
The following variables are supported in alert notifications:
Variable |
Description |
|---|---|
| ${AlertName} | The alert name. |
| ${AlertLevel} | The alert level. |
| ${MetricNames} | The names of the alert metrics. |
| ${AlertStartTime} | The time when the alert was triggered. |
| ${AlertUpdateTime} | The most recent alert time. |
| ${AlertCloseTime} | The time when the alert was resolved. Used in alert resolution notifications. |
| ${AlertResourceInfo} | Information about the alert object. |
| ${MViewInfo} | Materialized view information for alerts about incremental refresh delays or errors in a tenant. A single view is displayed as db_name.mv_name, and multiple views in the same database as db_name.mv_a,mv_b. If the database name is unavailable, only the view names are displayed. If no view information is available, - is displayed. |
| ${AlertSummary} | The alert summary. |
| ${AlertDescription} | The alert description. |
| ${AlertDetailUrl} | The URL of the alert details page. |
Example of a custom URL
For information about how to obtain the Webhook address of a DingTalk bot, a Lark bot, or a Telegram bot, see Obtain a webhook URL.
The following example shows how to call the DingTalk bot interface:
curl 'https://oapi.dingtalk.com/robot/send?access_token=********' \
-X 'POST' \
-H 'Accept: application/json' \
-H 'Content-Type: application/json;charset=UTF-8' \
--data '{"msgtype": "text", "text": {"content": "OceanBase Test"} }' \
--compressed
In the alert rule and notification template configuration, you need to enter the following information:
The custom URL is in the following format:
https://oapi.dingtalk.com/robot/send?access_token=********The alert notification template content is in the following format:
{ "msgtype": "text", "text": { "content": "Dear ${userName},\nHello!\n\nYour OBCloud database ${AlertTarget} triggered a ${MetricNames} (${AlertLevel}) alert at ${AlertStartTime}. Please review and address the alert promptly.\nAlert name: ${AlertName}\nAlert summary: ${AlertSummary}\nAlert description: ${AlertDescription}\nRelated metrics: ${MetricNames}\nTriggered at: ${AlertStartTime}\nLast updated at: ${AlertUpdateTime}\nRelated resources: ${AlertResourceInfo}\nAlert details: ${AlertDetailUrl}" } }