This topic describes how to use a DingTalk chatbot to send event notifications to a DingTalk group. Based on the event notifications, you can obtain the system events related to Elastic Compute Service (ECS) instances from the DingTalk group and handle the exceptions that occur when ECS instances are running.
Background information
Various system events may be generated when ECS instances are running, such as events related to changes in instance status and O&M events. For more information, see Summary. Some system events indicate that exceptions occur when ECS instances are running. O&M personnel must be informed of such system events at the earliest opportunity. If O&M personnel have a DingTalk group for communication, a DingTalk chatbot can be used to automatically send event notifications to the DingTalk group. This way, O&M personnel can handle exceptions at the earliest opportunity.
In the following procedure, a DingTalk chatbot and CloudMonitor are used:
Create a DingTalk chatbot for a DingTalk group.
Use the webhook URL of the DingTalk chatbot as the contact information of the CloudMonitor alert contact.
When you configure a subscription policy in the CloudMonitor console, select the alert contact group that includes the corresponding alert contact to receive alert notifications.
After the preceding manual operations are complete, the following procedure is automatically performed to send a notification:
When the underlying service of Alibaba Cloud detects a system event on an ECS instance, such as an event related to a change in instance status or an O&M event, the service pushes the event to the event center of CloudMonitor.
CloudMonitor sends a notification to the alert contact group based on your configured subscription policy. The contact information of the alert contact in the alert contact group includes the webhook URL of the DingTalk chatbot.
When the DingTalk chatbot detects an event, the chatbot sends a notification to the DingTalk group.
Step 1: Create a DingTalk chatbot
After a DingTalk chatbot is created, a webhook URL is generated. The webhook URL can be associated with other services such as CloudMonitor to receive notifications.
For information about how to create a DingTalk chatbot, see Steps 1, 3, 4, 5, and 6 in Create a DingTalk chatbot.
From 00:00:00 on September 1, 2023, non-enterprise DingTalk groups no longer support custom chatbots. Existing custom chatbots are not affected.
When you create a chatbot, add keywords one by one. For example, when CloudMonitor sends an event notification, the notification contains CloudMonitor. In this example, CloudMonitor is used as a keyword.
Step 2: Associate the DingTalk chatbot with a CloudMonitor subscription policy
This section describes how to associate a DingTalk chatbot with a CloudMonitor subscription policy. For more information, see Create an alert contact or alert contact group and Manage event subscription policies (recommended).
Log on to the CloudMonitor console.
Create an alert contact.
In the left-side navigation pane, choose .
Click Create Alert Contact.
In the Set Alert Contact panel, configure the alert contact as prompted.
To associate the DingTalk chatbot, enter the webhook URL that you saved in Step 1: Create a DingTalk chatbot in the DingTalk | Lark | WeCom | Slack Webhook(http|https): field.
Create an alert contact group.
Click the Alert Contact Group tab.
Click Create Alert Contact Group.
In the Create Alert Contact Group panel, configure the alert contact group as prompted.
To associate the DingTalk chatbot, add the alert contact you created to the alert contact group.
Create a subscription policy.
In the left-side navigation pane, choose
.On the System Event page, click the Event Subscription tab.
Click Create a subscription policy.
On the Create a subscription policy page, configure the alarm subscription settings as prompted.
Take note of the following items:
In this example, an event related to a change in the status of an ECS instance is used. The following figure shows how to configure a subscription policy for the event.
NoteThe event level of the change in the status of the ECS instance is Notification (Info). A large number of notifications may be sent for this type of event at a high frequency. Select the event for which you want to receive notifications based on your business requirements.
The notification settings must include the alert contact group that is associated with the DingTalk chatbot, as shown in the following figure.
Example of an event notification in a DingTalk group
After you complete the settings, you can change the status of an ECS instance and check whether an event notification is received in your DingTalk group. For example, when you stop an ECS instance, an event notification is received, as shown in the following figure.