Subscribe to ECS system event notifications by using CloudMonitor

更新时间:
复制 MD 格式

When your workloads run on ECS, we recommend that you subscribe to event notifications to monitor changes in the underlying environment. This helps ensure operational stability and enables automated O&M. This topic shows how to subscribe to ECS system events in the CloudMonitor console to receive automatic notifications.

Note

If you need low event latency or expect a large volume of events, we recommend using EventBridge to subscribe to ECS events. For more information, see Quickly subscribe to ECS events using EventBridge.

Background information

CloudMonitor is a service that monitors Alibaba Cloud resources and internet applications. You can use it to centrally manage and monitor system events from various cloud services. CloudMonitor provides a unified portal to query system events, letting you track the operational status of your services and receive alert notifications. For more information about CloudMonitor, see What is CloudMonitor?.

You can configure alert rules in CloudMonitor for all system events to receive timely alerts when an event occurs. CloudMonitor supports the following two alert methods:

  • Send alerts via SMS messages, email, and DingTalk robots.

  • Distribute events to your message queue, Log Service, Function Compute, or Webhook to automate exception handling.

Create a subscription policy

This topic uses the Instance:State:Change system event for ECS instances as an example to show how to subscribe to events.

  1. Log on to the Cloud Monitor console.

  2. In the left-side navigation pane, choose Event Center > Event Subscription.

    Note

    You can also create a subscription policy from the System Event menu as follows:

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

    2. In the Welcome to the New Event Center section, click Create Now.

  3. On the Subscription Policy tab, click Create Subscription Policy.

  4. On the Create a subscription policy page, configure the subscription policy.

    • Basic Information: Enter a name for the subscription policy.

    • Alert Subscription:

      • Subscription Type: Select System Event.

      • Subscription Scope:

        • Product: Select Elastic Compute Service (ECS).

        • Event Type: Select Status Notification.

        • Event Name: Select Instance:State:Change.

        • Event Level: Select Notification (Info).

        • Application Groups, Event Content, and Event Resources: Leave these parameters blank. This subscribes you to the Instance:State:Change system event for all ECS instances across all application groups in your account.

          Note

          For more information about the system events that ECS supports, see ECS.

    • Combined Noise Reduction: Use the default settings.

    • Notification: Create a notification configuration. For Custom Notification Method, keep the default setting.

      When you create a notification configuration, enter a name for the configuration, set Notification Settings to Set Notification Group Directly, select a Contact Group, and then click OK.

      Note

      For more information about how to create a notification configuration, see Create a notification configuration policy.

      The system sends alert notifications based on the notification methods configured for alert contacts in the contact group. For example, if an alert contact has a mobile number and an email address, and Custom Notification Method is set to the default, the alert contact receives only phone calls, SMS messages, and emails.

    • Push and Integration: No configuration is required.

      Note

      For more information about how to create a push channel, see Create a push channel.

Debug an event subscription

After you create a system event subscription, you can use the debugging feature to verify that the alert rule correctly triggers the configured message queue, Log Service, Function Compute, and Webhook.

  1. On the Subscription Policy tab, click Debug Event Subscription.

  2. In the Create Event Test panel, set Service to ECS and Name to Instance:State:Change.

    The system automatically generates the debugging content in JSON format.

    Sample code for an Instance:StateChange notification

    {
        "product": "ECS",
        "resourceId": "acs:ecs:cn-hangzhou:<account-id>:instance/<instance-id>",
        "level": "INFO",
        "instanceName": "<instance-name>",
        "regionId": "cn-hangzhou",
        "name": "Instance:StateChange",
        "content": {
            "resourceId": "<instance-id>",
            "instanceName": "<instance-name>",
            "instanceType": "<instance-type>",
            "state": "<state>",
            "privateIpAddress": "<private-ip>",
            "resourceType": "ALIYUN::ECS::Instance"
        },
        "status": "Normal"
    }
  3. Click OK.

    The system displays an Operation succeeded message. CloudMonitor automatically sends a test alert notification to the alert contacts using the notification methods specified in the subscription policy.

Related documents

You can automate the processing of ECS status change events by configuring a subsequent action, such as sending notifications to a message queue, in your CloudMonitor subscription policy. For more information, see Automated O&M for ECS instance status change events.