CloudMonitor can send alerts by using emails or webhooks. 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
Background information
CloudMonitor sends alert notifications to the specified URL by using the HTTP or HTTPs 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.
- 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
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:
|
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:
|
productGroupName | String | The name of the application group. |
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:
|
userId | String | The ID of the user. |
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****}×tamp=1508136760&productGroupName=test_Group