You can create a notification template to quickly set alert rules for business targets in batches.
Procedure
Log in to the OceanBase Cloud console.
In the left-side navigation pane, click Alerts.
Enter the Alert Management page and click the Alert Notification Templates tab.
On the Alert Notification Template tab, click Create Notification Template.
Configure the following template rules and click Create.
Notice
For security reasons, the alert notification template content must contain the keyword OBCloud or OceanBase.
Parameter Description Template 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 Type Select Instance or Tenant. Notification Effective Period The start and end times of the effective period must be on the same day and the start time must be earlier than the end time. If you do not specify the effective period, the alert rule takes effect 24 hours a day. Alert Notification Template Title The title displayed in alert notifications. You can use the ${alertName}format to input variables, where alertName represents the alert name.Note
The maximum length is 50 characters, which also applies to the parsed content of the input variables. Excess characters will be truncated.
Alert Notification Template Content The content displayed in an alert notification. You can preview and test the sending of the content on the right. You can enter variables in the format of ${alertName}, where alertName represents the name of the alert. For more information about the supported variables, see Alert variables.Note
The maximum length is 500 characters, which also applies to the parsed content of the input variables. Excess characters will be truncated.
Alert Resolution Notification Template Title The title displayed in alert resolution notifications. You can use the ${alertName}format to input variables, where alertName represents the alert name.Note
The maximum length is 50 characters, which also applies to the parsed content of the input variables. Excess characters will be truncated.
Alert Resolution Notification Template Content The content displayed in the alert resolution notification. You can preview and test the sending of the content on the right. You can enter variables in the format of ${alertName}, where alertName represents the name of the alert. For more information about the supported variables, see Alert variables.Note
The maximum length is 500 characters, which also applies to the parsed content of the input variables. Excess characters will be truncated.
After the alert rule 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 name of the alert. |
| ${AlertLevel} | The level of the alert. |
| ${MetricNames} | The name of the alert metric. |
| ${AlertStartTime} | The time when the alert was triggered. |
| ${AlertUpdateTime} | The time of the last alert. |
| ${AlertResourceInfo} | The description of the alert object. |
| ${AlertSummary} | The summary of the alert. |
| ${AlertDescription} | The description of the alert. |
| ${AlertDetailUrl} | The link to the alert. |
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}, Hello! Your OBCloud database ${AlertTarget} has triggered a ${MetricNames} (${AlertLevel}) alert at ${AlertStartTime}. Please pay attention to and handle the alert in a timely manner. Alert name: ${AlertName} Alert summary: ${AlertSummary} Alert description: ${AlertDescription} Related metrics: ${MetricNames} Triggered at: ${AlertStartTime} Last updated at: ${AlertUpdateTime} Related resources: ${AlertResourceInfo} Alert details: ${AlertDetailUrl}" } }
