MNS topics are integrated with CloudMonitor. Each MNS topic is a CloudMonitor instance. You can use CloudMonitor to retrieve the statistics of the topics, monitor the topics, and configure alarm rules for the topics.

Background information

You can monitor the following metrics in the CloudMonitor console:

  • The number of pushed messages within a specified period
  • The number of successfully pushed messages within a specified period
  • The success rate of message pushing within a specified period

These metrics can be applied in the following scenarios:

  • If a fixed number of messages are pushed every day for your businesses, you can monitor the number of pushed messages and the number of successfully pushed messages. If the number is lower than the expected value, errors may have occurred in your businesses. You can configure the alarm rules to provide reminder notifications.
  • Errors may occur on endpoints during message pushing. For example, an HTTP server crashes, and a network encounters exceptions. In this case, you can monitor the success rate of message pushing and configure the alarm rules to provide reminder notifications.

1. Select an MNS topic to be monitored.

  1. Log on to the MNS console.
  2. In the left-side navigation pane, select Topics.
  3. On the page that appears, select a topic to be monitored. In this example, the topic named topic-show-cloud-monitor that resides in China (Beijing) is selected.
  4. Click Subscription List to view the subscription details.

    As shown in the following figure, two subscriptions exist under this topic: valid-sub-show-cloud-monitor and invalid-sub-show-cloud-monitor. For the valid-sub-show-cloud-monitor subscription, messages can be successfully pushed because the specified endpoint is a valid queue. For the invalid-sub-show-cloud-monitor subscription, messages cannot be pushed because the specified endpoint is an invalid queue.

2. Find the corresponding CloudMonitor instance.

2.1 Log on to the CloudMonitor console. In the left-navigation pane of the Alibaba Cloud console, you can choose Products > CloudMonitor to go to the CloudMonitor console. In the left-side navigation pane, choose Cloud Service Monitoring > Message Service. Select the region. In this example, China North 2 (Beijing) is selected. Click Topics. In the topic list that appears, find the required MNS topic.

3. View monitoring data.

3.1 The following two charts are displayed: Notification Times and Success Rate. You can specify a time range to view the monitoring data. In this example, the specified time range is 2016-10-10 16:00:00 to 2016-10-10 16:40:00. You can click the alarm icon in the upper-right corner of each chart to configure alarm rules. You can also click the full screen icon to expand the view.

  • Notification Times: shows minute-by-minute total pushed messages within a specified period.
  • Success Rate: shows the success rate of message pushing within a specified period. The success rate is retrieved by dividing the number of pushed messages with the number of successfully pushed messages.

3.2 Click the full screen icon in the upper-right corner of the Notification Times chart to expand the view. Two lines correspond to the two subscriptions of the MNS topic. The black line indicates the subscription named valid-sub-show-cloud-monitor. As shown in the following figure, 24285 messages are pushed to the endpoint at 16:36.

3.3 The blue line indicates the subscription named invalid-sub-show-cloud-monitor. As shown in the following figure, 190 messages are pushed at 16:36. For this subscription, messages fail to be pushed due to the invalid endpoint, and retries are performed. The number of pushed messages changes based on the specified retry interval.

3.4 Click the full screen icon in the upper-right corner of the Success Rate chart to expand the view. Two lines correspond to the two subscriptions of the MNS topic. The black line indicates the subscription named valid-sub-show-cloud-monitor. As shown in the following figure, the success rate of message pushing is 100% at 16:36.

3.5 The blue line indicates the subscription named invalid-sub-show-cloud-monitor. As shown in the following figure, the success rate of message pushing is 0% at 16:36.

4. Configure alarm rules

4.1 Click Create Alarm Rule in the upper-right corner of the page or click the alarm icon in the upper-right corner of a chart to go to the Create Alarm Rule page. You can create multiple alarm rules at a time. Click +Add Alarm Rule if you want to add alarm rules. The following three alarm rules are configured in this example:

  • Rule 1: The number of pushed messages within each minute is retrieved every five minutes. If more than 1,000 messages are pushed in a minute, an alarm is triggered.
  • Rule 2: The number of successfully pushed messages within each minute is retrieved every five minutes. If less than 800 messages are pushed in each of three consecutive minutes, an alarm is triggered.
  • Rule 3: The success rate of message pushing within each minute is retrieved every five minutes. If the success rate is less than 80% for two consecutive minutes, an alarm is triggered.

4.2 After configuring alarm rules, you can specify the notification method. For example, you can send SMS notifications to the specified mobile numbers. You can specify the notification method based on your needs.