Use HTTP subscriptions for topics and ARMS to send multi-channel alerts for custom data

更新时间:
复制 MD 格式

This solution helps you distribute custom alert information to multiple notification channels, such as text messages, emails, and DingTalk groups. Using the HTTP subscription feature of the topic-based model in Simple Message Queue (formerly MNS) and the custom integration feature of Application Real-Time Monitoring Service, you can easily configure multi-channel synchronous notifications.

Benefits

  • Reliable data channel to trigger cloud product tasks: The core features of Simple Message Queue (formerly MNS), such as asynchronous decoupling, reliable transmission, and peak-load shifting, ensure stable and efficient delivery of notifications. This achieves loose coupling between applications and cloud services and maintains system stability during high concurrency.

  • Multiple notification channels: You can send alerts by phone, text message, or email, and through group chats or robots on instant messaging platforms such as DingTalk, Lark, and WeCom.

  • Flexible content formats: There are no restrictions on the format of alert content. Plain text, JSON, and other formats are supported.

  • Customizable notification policies: You can define different notification rules as needed. You can set parameters such as alert levels, time windows, and repetition counts. This allows for more precise and effective information delivery.

Solution architecture

image

Results

For example, you can send the following content to email, text message, and DingTalk channels at the same time.

Notification content: Welcome to <a href="">Simple Message Queue (formerly MNS)</a>, the preferred channel for messaging between cloud products.

The following shows the content received on the three channels:

image

Prerequisites

Procedure

Step 1: Create a Simple Message Queue (formerly MNS) topic

  1. Log on to the SMQ console.

  2. In the left-side navigation pane, choose Topic Model > Topics.

  3. In the top navigation bar, select a region.

  4. On the Topics page, click Create Topic. In the Create Topic panel, configure the following parameters and click OK.image

Step 2: Push messages from the topic to ARMS

  1. Log on to the ARMS console. In the left-side navigation pane, choose Alert Management > Integrations.

  2. On the Alert Integrations tab, click Custom Integration.

  3. In the Create Custom Event Integration dialog box, enter a Name and Description for the integration, and then click Save and Configure. In the API Configuration section of the integration details page, copy the URL.image

  4. Return to the Simple Message Queue (formerly MNS) console. In the navigation pane on the left, choose Topic Model > Subscriptions.

  5. On the Subscriptions page, click Create Subscription. In the Create Subscription panel, set the following parameters. Keep the default values for other parameters.

    Parameter

    Description

    Example

    Topic Name

    Select the topic that you created in Step 1: Create a Simple Message Queue (formerly MNS) topic.

    test

    Subscription Name

    Enter a name for the subscription.

    testsubscription

    Subscription Type

    Select HTTP.

    HTTP

    Endpoint

    Enter the integration URL that you copied.

    https://alerts.aliyuncs.com/api/v1/integrations/custom/J3aaq2qQza****

    Message Format

    If the message body is not in JSON format, select JSON. If the message body is in JSON format, select SIMPLIFIED. This ensures that the full content pushed to ARMS is in JSON format.

    JSON

  6. On the Topics page, find the topic that you created in Step 1: Create a Simple Message Queue (formerly MNS) topic. In the Action column, click Publish a message and perform the following operations.image

    Important

Step 3: Use the ARMS alert management system to parse the message body and configure a notification policy

  1. In the Alert Integrations list of the ARMS console, find the custom event integration that you created in Step 2: Push messages from the topic to ARMS. In the Actions column, click Edit.

  2. In the Event Mapping section of the integration details page, configure the mapping. In this example, SubscriptionName is mapped to the alert name (alertname), the alert level is set to MAX (P1), and the message body (Message) is mapped to the alert description (message). Then, click Save.image

  3. In the Actions column for the custom integration, choose More > New Notification Policy to create a notification policy for the integration.

  4. On the Notification Recipient tab, configure the following settings and click Save. You can keep the default configurations on the other tabs.

    • Notification Recipient: At ①, add the DingTalk robot that you created in the prerequisites. At ②, add the contact that you created in the prerequisites and select Text Message and Email as the notification methods.image

    • Send Recovery Notification: Select Do not send recovery notification.

    • Notification Template: In the notification content variable field, enter {{ for .alerts }} {{ .annotations.message }} {{ end }}.

      Email

      image

      Text message

      image

      DingTalk

      image

Step 4: Verify the result

  1. Return to the Simple Message Queue (formerly MNS) console. On the Topics page, find the topic that you created in Step 1: Create a Simple Message Queue (formerly MNS) topic. In the Action column, click Publish a message and perform the following operations.image

  2. Verify that the alert is received by the contact's email, as a text message, and by the DingTalk robot.