All Products
Search
Document Center

Elastic Compute Service:Send event notifications by using a DingTalk chatbot

Last Updated:Mar 12, 2024

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:

  1. Create a DingTalk chatbot for a DingTalk group.

  2. Use the webhook URL of the DingTalk chatbot as the contact information of the CloudMonitor alert contact.

  3. 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:

  1. 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.

  2. 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.

  3. 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.

    Note

    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).

  1. Log on to the CloudMonitor console.

  2. Create an alert contact.

    1. In the left-side navigation pane, choose Alerts > Alert Contacts.

    2. Click Create Alert Contact.

    3. 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.

  3. Create an alert contact group.

    1. Click the Alert Contact Group tab.

    2. Click Create Alert Contact Group.

    3. 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.

  4. Create a subscription policy.

    1. In the left-side navigation pane, choose Event Center > System Event.

    2. On the System Event page, click the Event Subscription tab.

    3. Click Create a subscription policy.

    4. 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.

        Note

        The 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.

        image.png

      • The notification settings must include the alert contact group that is associated with the DingTalk chatbot, as shown in the following figure.

        image.png

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.ding-notice