This topic describes how to use a DingTalk chatbot to send event notifications to a DingTalk group. You can understand the system events related to Elastic Compute Service (ECS) instances from the DingTalk group and handle the exceptions that occur when instances are running.
Various system events may be generated when instances are running, such as events about instance state changes and O&M events. Some system events indicate that exceptions occur when instances are running. O&M personnel must be aware of the system events in a timely manner. 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 so that O&M personnel can handle exceptions that have occurred in a quick manner.
- 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 an CloudMonitor alert rule, select the alert group that includes the corresponding alert contact to receive alert notifications.
- When the underlying service of Alibaba Cloud detects a system event on an ECS instance (such as an event about instance state changes or an O&M event), the service pushes the event to the event center of CloudMonitor.
- CloudMonitor sends a notification to the alert group based on your configured alert rules. The contact information of the alert contact in this group includes the webhook URL of the DingTalk chatbot.
- When the DingTalk chatbot detects an event, the chatbot sends a notification in the DingTalk group.
Step 1: Create a DingTalk chatbot
A webhook URL is generated after a DingTalk chatbot is created. The webhook URL can be associated with other services such as CloudMonitor to receive notifications.
- Start DingTalk and go to the DingTalk group in which you want to receive alert notifications.
- Go to the chatbot settings page.
- Click the Group Settings icon () in the upper-right corner of the DingTalk group.
- In the Group Settings panel, click Group Assistant.
- In the Group Assistant panel, click Add Robot.
- In the Add Robot section of the ChatBot dialog box, click the icon.
- In the Please choose which robot to add section, click Custom.
- In the Robot details dialog box, click Add.
- Configure the DingTalk chatbot as prompted. You must select at least one security setting. In this example, Custom Keywords is selected for Security Settings. If you select Custom Keywords, you must enter one or more keywords. When you use the DingTalk chatbot later, the DingTalk chatbot sends alert notifications to the DingTalk group only if the notifications contain at least one of the keywords.
For example, when CloudMonitor sends an event notification, the notification contains CloudMonitor. In this example, CloudMonitor is used as a keyword.
- Copy and save the webhook URL of the DingTalk chatbot.
Step 2: Associate the DingTalk chatbot with an alert rule
This section focuses on how to associate a DingTalk chatbot with an alert rule. For more information about the detailed operations, see Create an alert contact or alert contact group and Create a system event-triggered alert rule.
- Log on to the CloudMonitor console.
- Create an alert contact.
- In the left-side navigation pane, choose .
- On the Alert Contacts tab, click Create Alert Contact.
- In the Set Alert Contact panel, configure the alert contact as prompted. To associate the DingTalk bot, enter the webhook URL obtained in Step 1: Create a DingTalk chatbot in the Webhook or DingTalk Robot section.
- Create an alert group.
- Click the Alert Contact Group tab.
- Click Create Alert Contact Group.
- In the Create Alert Contact Group panel, configure the alert group as prompted. To associate the DingTalk chatbot, add the alert contact you created to the alert group.
- Create an alert rule.
- In the left-side navigation pane, choose .
- Click the Event Alert tab.
- Click Create Alert Rule.
- In the Create/Modify Event Alert panel, configure the alert rule as prompted. Take note of the following items:
- In this example, an event about an ECS instance state change is used. The following
figure shows how to configure an alert rule for the event.
Note The event level of the instance state change is INFO. A large number of notifications may be sent for this type of event at a high frequency. Select the event that you want to be notified of based on your business requirements.
- The notification methods must include the DingTalk chatbot, as shown in the following figure.
- In this example, an event about an ECS instance state change is used. The following figure shows how to configure an alert rule for the event.