Subscribe to event notifications

Updated at:

ApsaraDB for MongoDB integrates with CloudMonitor. You can subscribe to system events and set alert rules to track events and instance health in real time.

Background

CloudMonitor provides two ways to deliver alert notifications when a system exception occurs, such as a cloud service failure.

  • Subscribe to events: Receive event notifications through text messages, email, or DingTalk chatbots for a fast response.

  • Set alerts: Route alerts to Simple Message Queue, Function Compute, a callback URL, or Simple Log Service to automate exception handling.

Procedure

Subscribe to an event

The following example uses the Instance Failure Start system event to show how to subscribe to an event.

  1. Log on to the CloudMonitor console.

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

  3. On the Subscription Policy tab, click Create a subscription policy.

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

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

    • Alert Subscription:

      • Set Subscription Type to System Event.

      • In the Subscription Scope section, set Product to ApsaraDB for MongoDB, Event Type to Exception, Event Name to Instance Failure Start, and Event Level to Critical. Do not configure the Application Group, Event Content, or Event Resources parameters. This subscribes your account to the Instance Failure Start system event for all ApsaraDB for MongoDB instances across all application groups.

        Note

        For more information about the system events supported by ApsaraDB for MongoDB, see System events.

    • Combined Noise Reduction: Use the default settings.

    • Notification: Create a notification configuration. Use the default setting for Custom Notification Method.

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

      Note

      For more information about how to create a notification configuration, see Manage notification configurations.

      The system sends alert notifications based on the contact methods configured for the alert contacts in the group. For example, if an alert contact has both a phone number and an email address, and Custom Notification Method uses the default method, the contact will receive only alert calls, text messages, and emails.

    • Push and Integration: No configuration is required.

      Note

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

    Table 1. Subscription policy parameters

    Section

    Parameter

    Description

    Basic Infomation

    Name

    The subscription policy name.

    Description

    The subscription policy description.

    Alert Subscription

    Subscription Type

    The alert subscription type. Valid values:

    • System Event: System events include failure and O&M events for various cloud products. By subscribing to system events, you can receive notifications or trigger external systems when an event occurs. You must configure the subscription scope for system events, including Product, Event Type, Event Name, Event Level, Application Group, Event Content, and Event Resources.

      • Event Content: This field performs a containment match for keywords. To specify multiple keywords, separate them with commas (,). In whitelist mode, an event matches if its content includes any of the specified keywords. In blacklist mode, an event matches only if its content includes all of the specified keywords. For example, if you are in whitelist mode and enter re,1754xxxxx651403, all events that contain either re or 1754xxxxx651403 are returned.

        "content": {"invokeId": "t-bj05sxXXXXXXa5xq8","repeats": 1,"finishTime": "2025-08-05T17:07:17Z","commandName": "cmd-2025-08-06","instanceId": "i-2ze61xxxxxugk0zoh7","repeatMode": "Once","playerUid": 1754xxxxx651403,"exitCode": 0,"startTime": "2025-08-05T17:07:14Z","ownerId": 18250xxxxx44564,"commandId": "c-bj05sxxxxxxog00","invocationStatus": "Success"}
      • Event resource: The ResourceId of the corresponding cloud product, such as acs:ecs:cn-shanghai:{uid}:instance/{instanceId}. The input box matches resources that contain the keywords you enter. To specify multiple keywords, separate them with a comma (,). In whitelist mode, a resource is matched if it contains any of the specified keywords. In blacklist mode, a resource is matched only if it contains all of the specified keywords. For example, in whitelist mode, if you enter instanceId_1,instanceId_2, events from instances with the ID instanceId_1 or instanceId_2 are matched.

    • Threshold Events: When a threshold-based alert rule is triggered, CloudMonitor also generates a threshold event. Subscribing to threshold events lets you control and customize alert notifications at a finer granularity, such as combined noise reduction and custom notification methods. You must set the subscription scope for threshold events, including Product Category, Metric, Severity Level, and Application Group.

    Combined Noise Reduction

    Note

    If you do not configure a merge rule, all alerts accepted by the subscription policy are merged by default.

    Merge Content

    Select a merge dimension from the Subscription Type section of the Subscription Scope.

    Noise Reduction

    Reduces the frequency of alert notifications. Options:

    • Conditional trigger, suppress after trigger: A mute period (default: 5 minutes) begins if an alert is triggered a specified number of consecutive times (default: 5) within a specified period (default: 5 minutes). During the mute period, no duplicate notifications are sent. This process repeats after the mute period ends.

    • Direct trigger, suppress after trigger: A notification is sent immediately after an alert is triggered. Then, a mute period (default: 5 minutes) begins, during which no duplicate notifications are sent. This process repeats after the mute period ends.

    • Direct trigger, no suppression (uses system default anti-storm settings): A notification is sent immediately after an alert is triggered.

      Note

      The default anti-storm rules are as follows:

      • Text messages: 5 per 2 minutes.

      • Phone calls: 3 per 2 minutes.

      • Emails: Up to 50 per 5 minutes.

    Notification

    Notification Configurations

    When system event or threshold event conditions are met, notifications are sent directly to alert contacts or to different contacts based on the alert level.

    You can select an existing notification configuration or click Create Notification Configuration to create a new one.

    For more information about how to configure a notification policy, see Manage notification configurations.

    Custom Notification Method

    Customizes alert notification methods.

    Click Edit next to a notification method to change the Notification Templates and Alert Level.

    Push and Integration

    Push Channel

    The channel for pushing alert notifications. To create one:

    1. Click Create New Push.

    2. Select an existing push channel or click Add Channel to create a new one.

      For more information about how to configure parameters for a push channel, see Manage push channels.

  5. Click Submit.

  6. Debug the event subscription.

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

    2. In the Create Event Test panel, set Product to ApsaraDB for MongoDB and Name to Instance Failure Start.

      The system automatically generates the debugging content in JSON format.

    3. Click OK.

      The system displays an Operation Successful message. CloudMonitor then automatically sends a test alert notification to the alert contacts based on the notification methods in the subscription policy.

Set an alert rule

  1. Create an alert contact or an alert contact group. For more information, see Create an alert contact or an alert contact group.

  2. Log on to the ApsaraDB for MongoDB console.

  3. In the left-side navigation pane, click Replica Set Instances or Sharded Cluster Instances depending on your instance type.

  4. In the upper-left corner of the page, select the resource group and region for your instance.

  5. Click the ID of the target instance, or click Actions in the Manage column.

  6. Configure event alerts.

    1. In the left-side navigation pane of the instance details page, click Alert Rules.

    2. Click Set Alert Rule to go to the CloudMonitor console.

    3. Click Create Alert Rule.

    4. In the Create Alert Rule panel, configure the following parameters.

      Parameter

      Description

      Product

      No modification required. The default value is the type of the current instance.

      Resource Scope

      The cloud product resources to which the alert rule applies. Default value: Instances.

      Related Resource

      No modification required. The default value is the ID of the current instance.

      Rule Description

      The core of the alert rule. An alert is triggered when monitoring data meets the specified conditions. To configure:

      1. Click Add Rule.

      2. In the Set Rule Description panel, enter a Rule Name and then set the Metric Type.

        • Single Metric: Select a metric and then set a threshold and an alert level for it.

        • Multiple Metrics: Select an alert level and then set alert conditions for two or more metrics.

        • Dynamic Threshold: For more information about intelligent thresholds, see Overview and Create an alert rule for an intelligent threshold.

      3. Click OK.

      Note

      For more information about how to set complex alert conditions, see Expressions for alert rules.

      Mute Period

      The interval between alert notifications for an unresolved issue. Valid values: 5 Minutes, 15 Minutes, 30 Minutes, 60 Minutes, 3 Hours, 6 Hours, 12 Hours, and 24 Hours.

      When a metric exceeds its threshold, CloudMonitor triggers an alert and begins a mute period. During this period, no further notifications are sent. If the issue persists after the mute period ends, another notification is sent.

      For example, if you set the Mute Period to 12 Hours, CloudMonitor sends another alert notification after 12 hours if the alert is not resolved.

      Effective Period

      The period during which the alert rule is active. Notifications are sent only during this period.

      Note

      When an alert rule is outside its effective period, no alert notifications are sent. However, alert history records are still displayed in the Alert History list.

      Alert Contact Group

      The contact group that receives alert notifications.

      An alert contact group can contain one or more alert contacts. Notifications for an application group are sent to the contacts in this group.

      For more information about how to create alert contacts and alert contact groups, see Create an alert contact or an alert contact group.

      Tags

      The alert rule tag, consisting of a tag key and a tag value.

      Note

      You can add up to six tags.

      Alert Callback

      A publicly accessible URL that receives alert information from CloudMonitor via POST requests. Only HTTP is supported. For more information, see Use a threshold-triggered alert callback.

      To test the connectivity of the callback URL, perform the following steps:

      1. Click Test to the right of the callback URL.

        In the Webhook Test panel, you can check the connectivity of the callback URL based on the status code and test results returned by the webhook.

        Note

        You can also set the Callback Template Type and Language re for the webhook, and then click Test again to get the corresponding test results.

      2. Click Close.

      Note

      To configure this parameter, click Advanced Settings.

      Auto Scaling

      If you enable the Auto Scaling switch, the corresponding scaling rule is triggered when an alert occurs. You must specify the Region, ESS Group, and ESS Rule for Auto Scaling.

      Note

      To configure this parameter, click Advanced Settings.

      Simple Log Service

      If you enable the Simple Log Service switch, alert information is sent to a Logstore in Simple Log Service when an alert occurs. You must specify the Region, ProjectName, and Logstore for Simple Log Service.

      For more information about how to create a project and a Logstore, see Use Logtail to collect and analyze text logs on ECS instances.

      Note

      To configure this parameter, click Advanced Settings.

      Simple Message Queue (formerly MNS) - Topic

      If you enable the Simple Message Queue (formerly MNS) - Topic switch, alert information is sent to a topic in Simple Message Queue when an alert occurs. You must specify the region and topic for Simple Message Queue.

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

      Note

      To configure this parameter, click Advanced Settings.

      Function Compute

      If you enable the Function Compute switch, alert notifications are sent to Function Compute for processing when an alert occurs. You must specify the region, service, and function for Function Compute.

      For more information about how to create a service and a function, see Create a function.

      Note

      To configure this parameter, click Advanced Settings.

      No-Data Handling

      How to handle alerts when no monitoring data is available. Valid values:

      • Do not do anything (default)

      • Send alert notifications

      Note

      To configure this parameter, click Advanced Settings.

    5. Click OK.

Related APIs

CloudMonitor API

Description

PutEventRule

Creates or modifies an alert rule for an event.