CloudMonitor can send alerts by using emails or DingTalk chatbots. CloudMonitor can also send alerts by using the alert callback feature. You can handle alerts in a flexible manner. This topic describes how to use the alert callback feature to send notifications about threshold-triggered alerts to your O&M system or notification system.

Prerequisites

The public URL of your O&M system or notification system is available. The URL can be used to access your O&M system or notification system.

Background information

CloudMonitor sends alert notifications to the specified URL by using the HTTP POST method. You must add the following classless inter-domain routing (CIDR) blocks to the whitelist of your firewall:47.74.206.0/26, 47.74.206.64/26, 47.74.206.128/26, and 47.74.206.192/26. After you receive alert notifications, you can resolve issues based on the content of the alert notifications.

If an alert callback fails, CloudMonitor retries up to three times. The timeout period of each callback request is 5 seconds.

You cannot configure multiple threshold-triggered alert callbacks at a time in the CloudMonitor console. To configure multiple threshold-triggered alert callbacks, perform the following steps:
  • Call the CreateMetricRuleTemplate operation to create an alert template, specify a callback URL, and then call the ApplyMetricRuleTemplate operation to apply the alert template to a specified application group. For more information, see CreateMetricRuleTemplate and ApplyMetricRuleTemplate.
  • Call the PutGroupMetricRule operation to create an alert rule for or modify the alert rule of the application group, and specify a callback URL. For more information, see PutGroupMetricRule.

Procedure

  1. Log on to the CloudMonitor console.
  2. In the left-side navigation pane, choose Alerts > Alert Rules.
  3. On the Alert Rules page, find the alert rule that you want to modify and click Modify in the Actions column.
    Note You can also create an alert rule. For more information, see Create an alert rule.
  4. In the Create Alert Rule panel, enter a callback URL in the HTTP WebHook field.
  5. Click OK.

Result

If the alert rule is triggered, CloudMonitor sends an alert notification to the callback URL by using the HTTP POST method. The following table describes the parameters of an HTTP POST request.

Parameter Type Description
alertName String The name of the alert.
alertState String The status of the alert. Valid values:
  • OK: normal.
  • ALERT: The alert is triggered.
  • INSUFFICIENT_DATA: No data is found.
curValue String The value of the metric when the alert is triggered or cleared. The metric is specified in the alert rule based on which the alert is triggered.
dimensions String The object for which the alert is triggered. Example: {userId=110803419679****, instanceId=i-8psdh7l6lphbn10l****}.
expression String The alert conditions.
instanceName String The name of the instance.
metricName String The name of the metric. For more information about metric names, see Appendix 1: Metrics.
metricProject String The name of the cloud service. The value of this parameter is the same as the value of the namespace parameter. For more information about cloud service names, see Appendix 1: Metrics.
namespace String The namespace of the cloud service. The value of this parameter is the same as the value of the metricProject parameter. For more information about the namespaces of cloud services, see Appendix 1: Metrics.
preTriggerLevel String The severity level of the previous alert that is triggered. Valid values:
  • CRITICAL: critical
  • WARN: warning
  • INFO: information
ruleId String The ID of the alert rule based on which the current alert is triggered.
timestamp String The timestamp when the current alert is triggered.
triggerLevel String The severity level of the current alert that is triggered. Valid values:
  • CRITICAL: critical
  • WARN: warning
  • INFO: information
userId String The ID of the user.
Sample POST request
Content-Type: application/x-www-form-urlencoded; charset=UTF-8

expression=$Average>=95&metricName=Host.mem.usedutilization&instanceName=instance-name-****&signature=eEq1zHuCUp0XSmLD8p8VtTKF****&metricProject=acs_ecs_dashboard&userId=110803419679****&curValue=97.39&alertName=Basic monitoring-ECS-memory usage&namespace=acs_ecs_dashboard&triggerLevel=WARN&alertState=ALERT&preTriggerLevel=WARN&ruleId=applyTemplateee147e59-664f-4033-a1be-e9595746****&dimensions={userId=110803419679****), instanceId=i-8psdh7l6lphbn10l****}&timestamp=1508136760