This topic describes how to call the CloudMonitor API to set alert rules for the monitoring metrics of Server Load Balancer (SLB).

Prerequisites

  • Note that SLB is the product label that has been configured in CloudMonitor.
  • Note that the namespace of SLB in CloudMonitor is acs_slb_dashboard. For more information about how to obtain the value, see DescribeProjectMeta.

Background information

The following figure shows the procedure of setting alert rules by calling the CloudMonitor API.

Flowchart

The procedure is as follows:

  1. You can call the DescribeMetricMetaList operation to query the descriptions of SLB time series metrics that are supported in CloudMonitor. For more information, see Monitoring and alerting metrics.
  2. You can call the PutContact operation to create or modify an alert contact.
  3. You can call the PutContactGroup operation to create or modify an alert contact group.
  4. You can call the PutResourceMetricRule operation to set an alert rule for a performance metric of a resource.
  5. You can call the DescribeMetricRuleList operation to query a list of alert rules.

A TCP listener has been configured for the lb-bp1rbwvouuyipbc*** instance. This topic describes how to set thresholds for triggering alerts of Critical, Warn, and Info when the number of abnormal ECS instances exceeds the specified thresholds.

DescribeMetricMetaList

You can call this operation to query the descriptions of time series metrics that are supported in CloudMonitor. For more information, see DescribeMetricMetaList.

  1. Set the value of the request parameter Namespace to acs_slb_dashboard, and keep all other parameters as default.
    Sample requests:
    http(s)://[Endpoint]/? Action=DescribeMetricMetaList
    &Namespace=acs_slb_dashboard
    &<Common request parameters>
  2. View the time series metrics of SLB based on the returned parameters. Check whether the Qps parameter is returned in this example.
    Sample responses:
    {
        "TotalCount": 53, 
        "RequestId": "789846B4-56FC-4681-998C-5B7DBDFBE28F", 
        "Resources": {
            "Resource": [
                {
                    "MetricName": "ActiveConnection", 
                    "Periods": "60,300", 
                    "Description": "current active connections of the port", 
                    "Dimensions": "userId,instanceId,port,protocol", 
                    "Labels": "[{\"name\":\"alertUnit\",\"value\":\"Count\"},{\"name\":\"minAlertPeriod\",\"value\":\"60\"},{\"name\":\"metricCategory\",\"value\":\"port\"},{\"name\":\"is_alarm\",\"value\":\"true\"}]", 
                    "Unit": "Count", 
                    "Statistics": "Average,Minimum,Maximum", 
                    "Namespace": "acs_slb_dashboard"
                }, 
                {
                    "MetricName": "DropConnection", 
                    "Periods": "60,300", 
                    "Description": "", 
                    "Dimensions": "userId,instanceId,port,protocol", 
                    "Labels": "[{\"name\":\"alertUnit\",\"value\":\"Count/Second\"},{\"name\":\"minAlertPeriod\",\"value\":\"60\"},{\"name\":\"metricCategory\",\"value\":\"port\"},{\"name\":\"is_alarm\",\"value\":\"true\"}]", 
                    "Unit" : "Counts/s" 
                    "Statistics": "Average,Minimum,Maximum", 
                    "Namespace": "acs_slb_dashboard"
                }, 
                {
                    "MetricName": "DropPacketRX", 
                    "Periods": "60,300", 
                    "Description": "", 
                    "Dimensions": "userId,instanceId,port,protocol", 
                    "Labels": "[{\"name\":\"alertUnit\",\"value\":\"Count/Second\"},{\"name\":\"minAlertPeriod\",\"value\":\"60\"},{\"name\":\"metricCategory\",\"value\":\"port\"},{\"name\":\"is_alarm\",\"value\":\"true\"}]", 
                    "Unit": "Count/s", 
                    "Statistics": "Average,Minimum,Maximum", 
                    "Namespace": "acs_slb_dashboard"
                }, 
                {
                    "MetricName": "DropPacketTX", 
                    "Periods": "60,300", 
                    "Description": "", 
                    "Dimensions": "userId,instanceId,port,protocol", 
                    "Labels": "[{\"name\":\"alertUnit\",\"value\":\"Count/Second\"},{\"name\":\"minAlertPeriod\",\"value\":\"60\"},{\"name\":\"metricCategory\",\"value\":\"port\"},{\"name\":\"is_alarm\",\"value\":\"true\"}]", 
                    "Unit": "Count/s", 
                    "Statistics": "Average,Minimum,Maximum", 
                    "Namespace": "acs_slb_dashboard"
                }, 
                {
                    "MetricName": "DropTrafficRX", 
                    "Periods": "60,300", 
                    "Description": "", 
                    "Dimensions": "userId,instanceId,port,protocol", 
                    "Labels": "[{\"name\":\"alertUnit\",\"value\":\"bits/s\"},{\"name\":\"minAlertPeriod\",\"value\":\"60\"},{\"name\":\"metricCategory\",\"value\":\"port\"},{\"name\":\"is_alarm\",\"value\":\"true\"}]", 
                    "Unit": "bits/s", 
                    "Statistics": "Average,Minimum,Maximum", 
                    "Namespace": "acs_slb_dashboard"
                }, 
                {
                    "MetricName": "DropTrafficTX", 
                    "Periods": "60,300", 
                    "Description": "", 
                    "Dimensions": "userId,instanceId,port,protocol", 
                    "Labels": "[{\"name\":\"alertUnit\",\"value\":\"bits/s\"},{\"name\":\"minAlertPeriod\",\"value\":\"60\"},{\"name\":\"metricCategory\",\"value\":\"port\"},{\"name\":\"is_alarm\",\"value\":\"true\"}]", 
                    "Unit":"bits/s" 
                    "Statistics":"Average,Minimum,Maximum", 
                    "Namespace": "acs_ecs_dashboard",
                }, 
                {
                    "MetricName": "GroupTrafficRX", 
                    "Periods": "60", 
                    "Description": "", 
                    "Dimensions": "groupId", 
                    "Labels": "[{\"name\":\"alertUnit\",\"value\":\"bits/s\"},{\"name\":\"minAlertPeriod\",\"value\":\"60\"},{\"name\":\"metricCategory\",\"value\":\"groupId\"},{\"name\":\"is_alarm\",\"value\":\"true\"}]", 
                    "Unit": "bits/s", 
                    "Statistics": "Average,Minimum,Maximum,Sum", 
                    "Namespace": "acs_slb_dashboard"
                }, 
                {
                    "MetricName": "GroupTrafficTX", 
                    "Period": "60", 
                    "Description": "", 
                    "Dimensions": "groupId", 
                    "Labels": "[{\"name\":\"alertUnit\",\"value\":\"bits/s\"},{\"name\":\"minAlertPeriod\",\"value\":\"60\"},{\"name\":\"metricCategory\",\"value\":\"groupId\"},{\"name\":\"is_alarm\",\"value\":\"true\"}]", 
                    "Unit": "bits/s", 
                    "Statistics": "Average,Minimum,Maximum,Sum", 
                    "Namespace": "acs_slb_dashboard"
                }, 
                {
                    "MetricName": "HeathyServerCount", 
                    "Periods": "60,300", 
                    "Description": "Number of healthy ECS instances", 
                    "Dimensions": "userId,instanceId,port,vip", 
                    "Labels": "[{\"name\":\"alertUnit\",\"value\":\"Count\"},{\"name\":\"minAlertPeriod\",\"value\":\"60\"},{\"name\":\"metricCategory\",\"value\":\"port\"},{\"name\":\"is_alarm\",\"value\":\"true\"}]", 
                    "Unit": "Count", 
                    "Statistics": "Average,Minimum,Maximum", 
                    "Namespace": "acs_slb_dashboard"
                }, 
                {
                    "MetricName": "InactiveConnection", 
                    "Periods": "60,300", 
                    "Description": "Number of inactive connections on the port", 
                    "Dimensions": "userId,instanceId,port,protocol", 
                    "Labels": "[{\"name\":\"alertUnit\",\"value\":\"Count\"},{\"name\":\"minAlertPeriod\",\"value\":\"60\"},{\"name\":\"metricCategory\",\"value\":\"port\"},{\"name\":\"is_alarm\",\"value\":\"true\"}]", 
                    "Unit":"Count" 
                    "Statistics": "Average,Minimum,Maximum", 
                    "Namespace": "acs_slb_dashboard"
                }, 
                {
                    "MetricName": "InstanceActiveConnection", 
                    "Periods": "60,300", 
                    "Description": "", 
                    "Dimensions": "userId,instanceId", 
                    "Labels": "[{\"name\":\"alertUnit\",\"value\":\"Count/Second\"},{\"name\":\"minAlertPeriod\",\"value\":\"60\"},{\"name\":\"metricCategory\",\"value\":\"instanceId\"},{\"name\":\"is_alarm\",\"value\":\"true\"}]", 
                    "Unit": "Count/s", 
                    "Statistics": "Average,Minimum,Maximum", 
                    "Namespace": "acs_slb_dashboard"
                }, 
                {
                    "MetricName": "InstanceDropConnection", 
                    "Periods": "60,300", 
                    "Description": "", 
                    "Dimensions": "userId,instanceId", 
                    "Labels": "[{\"name\":\"alertUnit\",\"value\":\"Count/Second\"},{\"name\":\"minAlertPeriod\",\"value\":\"60\"},{\"name\":\"metricCategory\",\"value\":\"instanceId\"},{\"name\":\"is_alarm\",\"value\":\"true\"}]", 
                    "Unit": "Count/s", 
                    "Statistics": "Average,Minimum,Maximum", 
                    "Namespace": "acs_slb_dashboard"
                }, 
                {
                    "MetricName": "InstanceDropPacketRX", 
                    "Periods": "60,300", 
                    "Description": "", 
                    "Dimensions": "userId,instanceId", 
                    "Labels": "[{\"name\":\"alertUnit\",\"value\":\"Count/Second\"},{\"name\":\"minAlertPeriod\",\"value\":\"60\"},{\"name\":\"metricCategory\",\"value\":\"instanceId\"},{\"name\":\"is_alarm\",\"value\":\"true\"}]", 
                    "Unit": "Count/s", 
                    "Statistics": "Average,Minimum,Maximum", 
                    "Namespace": "acs_slb_dashboard"
                }, 
                {
                    "MetricName": "InstanceDropPacketTX", 
                    "Periods": "60,300", 
                    "Description": "", 
                    "Dimensions": "userId,instanceId", 
                    "Labels": "[{\"name\":\"alertUnit\",\"value\":\"Count/Second\"},{\"name\":\"minAlertPeriod\",\"value\":\"60\"},{\"name\":\"metricCategory\",\"value\":\"instanceId\"},{\"name\":\"is_alarm\",\"value\":\"true\"}]", 
                    "Unit": "Count/s", 
                    "Statistics": "Average,Minimum,Maximum", 
                    "Namespace": "acs_slb_dashboard"
                }, 
                {
                    "MetricName": "InstanceDropTrafficRX", 
                    "Periods": "60,300", 
                    "Description": "", 
                    "Dimensions": "userId,instanceId", 
                    "Labels": "[{\"name\":\"alertUnit\",\"value\":\"bits/s\"},{\"name\":\"minAlertPeriod\",\"value\":\"60\"},{\"name\":\"metricCategory\",\"value\":\"instanceId\"},{\"name\":\"is_alarm\",\"value\":\"true\"}]", 
                    "Unit": "bits/s", 
                    "Statistics": "Average,Minimum,Maximum", 
                    "Namespace": "acs_slb_dashboard"
                }, 
                {
                    "MetricName": "InstanceDropTrafficTX", 
                    "Periods": "60,300", 
                    "Description": "", 
                    "Dimensions": "userId,instanceId", 
                    "Labels": "[{\"name\":\"alertUnit\",\"value\":\"bits/s\"},{\"name\":\"minAlertPeriod\",\"value\":\"60\"},{\"name\":\"metricCategory\",\"value\":\"instanceId\"},{\"name\":\"is_alarm\",\"value\":\"true\"}]", 
                    "Unit": "bits/s", 
                    "Statistics": "Average,Minimum,Maximum", 
                    "Namespace": "acs_slb_dashboard"
                }, 
                {
                    "MetricName": "InstanceInactiveConnection", 
                    "Periods":"60,300", 
                    "Description": "", 
                    "Dimensions": "userId,instanceId", 
                    "Labels": "[{\"name\":\"alertUnit\",\"value\":\"Count/Second\"},{\"name\":\"minAlertPeriod\",\"value\":\"60\"},{\"name\":\"metricCategory\",\"value\":\"instanceId\"},{\"name\":\"is_alarm\",\"value\":\"true\"}]", 
                    "Unit": "Count/s", 
                    "Statistics": "Average,Minimum,Maximum", 
                    "Namespace": "acs_slb_dashboard"
                }, 
                {
                    "MetricName": "InstanceMaxConnection", 
                    "Periods": "60,300", 
                    "Description": "", 
                    "Dimensions": "userId,instanceId", 
                    "Labels": "[{\"name\":\"alertUnit\",\"value\":\"Count/Second\"},{\"name\":\"minAlertPeriod\",\"value\":\"60\"},{\"name\":\"metricCategory\",\"value\":\"instanceId\"},{\"name\":\"is_alarm\",\"value\":\"true\"}]", 
                    "Unit": "Count/s", 
                    "Statistics":"Average,Minimum,Maximum", 
                    "Namespace": "acs_slb_dashboard"
                }, 
                {
                    "MetricName": "InstanceMaxConnectionUtilization", 
                    "Periods": "60,300", 
                    "Description": "Maximum connection utilization", 
                    "Dimensions": "userId,instanceId", 
                    "Labels": "[{\"name\":\"alertUnit\",\"value\":\"%\"},{\"name\":\"minAlertPeriod\",\"value\":\"60\"},{\"name\":\"metricCategory\",\"value\":\"instanceId\"},{\"name\":\"is_alarm\",\"value\":\"true\"}]", 
                    "Unit": "%", 
                    "Statistics":"Average,Minimum,Maximum", 
                    "Namespace": "acs_slb_dashboard"
                }, 
                {
                    "MetricName": "InstanceNewConnection", 
                    "Periods": "60,300", 
                    "Description": "", 
                    "Dimensions": "userId,instanceId", 
                    "Labels": "[{\"name\":\"alertUnit\",\"value\":\"Count/Second\"},{\"name\":\"minAlertPeriod\",\"value\":\"60\"},{\"name\":\"metricCategory\",\"value\":\"instanceId\"},{\"name\":\"is_alarm\",\"value\":\"true\"}]", 
                    "Unit": "Count/s", 
                    "Statistics": "Average,Minimum,Maximum", 
                    "Namespace": "acs_slb_dashboard"
                }, 
                {
                    "MetricName": "InstanceNewConnectionUtilization", 
                    "Periods": "60,300", 
                    "Description": "New connection utilization", 
                    "Dimensions": "userId,instanceId", 
                    "Labels": "[{\"name\":\"alertUnit\",\"value\":\"%\"},{\"name\":\"minAlertPeriod\",\"value\":\"60\"},{\"name\":\"metricCategory\",\"value\":\"instanceId\"},{\"name\":\"is_alarm\",\"value\":\"true\"}]", 
                    "Unit": "%", 
                    "Statistics": "Average,Maximum,Minimum", 
                    "Namespace": "acs_slb_dashboard"
                }, 
                {
                    "MetricName": "InstancePacketRX", 
                    "Periods": "60,300", 
                    "Description": "", 
                    "Dimensions": "userId,instanceId", 
                    "Labels": "[{\"name\":\"alertUnit\",\"value\":\"Count/Second\"},{\"name\":\"minAlertPeriod\",\"value\":\"60\"},{\"name\":\"metricCategory\",\"value\":\"instanceId\"},{\"name\":\"is_alarm\",\"value\":\"true\"}]", 
                    "Unit": "Count/s", 
                    "Statistics": "Average,Minimum,Maximum", 
                    "Namespace": "acs_slb_dashboard"
                }, 
                {
                    "MetricName": "InstancePacketTX", 
                    "Periods": "60,300", 
                    "Description": "", 
                    "Dimensions": "userId,instanceId", 
                    "Labels": "[{\"name\":\"alertUnit\",\"value\":\"Count/Second\"},{\"name\":\"minAlertPeriod\",\"value\":\"60\"},{\"name\":\"metricCategory\",\"value\":\"instanceId\"},{\"name\":\"is_alarm\",\"value\":\"true\"}]", 
                    "Unit": "Count/s", 
                    "Statistics": "Average,Minimum,Maximum", 
                    "Namespace": "acs_slb_dashboard"
                }, 
                {
                    "MetricName": "InstanceQps", 
                    "Periods": "60,300", 
                    "Description": "", 
                    "Dimensions": "userId,instanceId", 
                    "Labels": "[{\"name\":\"alertUnit\",\"value\":\"Count/s\"},{\"name\":\"minAlertPeriod\",\"value\":\"60\"},{\"name\":\"metricCategory\",\"value\":\"instanceId\"},{\"name\":\"is_alarm\",\"value\":\"true\"}]", 
                    "Unit" : "Counts/s" 
                    "Statistics": "Average", 
                    "Namespace": "acs_slb_dashboard"
                }, 
                {
                    "MetricName": "InstanceQpsUtilization", 
                    "Periods": "60,300", 
                    "Description": "QPS utilization", 
                    "Dimensions": "userId,instanceId", 
                    "Labels": "[{\"name\":\"alertUnit\",\"value\":\"%\"},{\"name\":\"minAlertPeriod\",\"value\":\"60\"},{\"name\":\"metricCategory\",\"value\":\"instanceId\"},{\"name\":\"is_alarm\",\"value\":\"true\"}]", 
                    "Unit": "%", 
                    "Statistics": "Average,Maximum,Minimum", 
                    "Namespace": "acs_slb_dashboard"
                }, 
                {
                    "MetricName": "InstanceRt", 
                    "Periods": "60,300", 
                    "Description": "", 
                    "Dimensions": "userId,instanceId", 
                    "Labels": "[{\"name\":\"alertUnit\",\"value\":\"ms\"},{\"name\":\"minAlertPeriod\",\"value\":\"60\"},{\"name\":\"metricCategory\",\"value\":\"instanceId\"},{\"name\":\"is_alarm\",\"value\":\"true\"}]", 
                    "Unit": "ms", 
                    "Statistics": "Average", 
                    "Namespace": "acs_slb_dashboard"
                }, 
                {
                    "MetricName": "InstanceStatusCode2xx", 
                    "Periods": "60,300", 
                    "Description": "", 
                    "Dimensions": "userId,instanceId", 
                    "Labels": "[{\"name\":\"alertUnit\",\"value\":\"Count/Second\"},{\"name\":\"minAlertPeriod\",\"value\":\"60\"},{\"name\":\"metricCategory\",\"value\":\"instanceId\"},{\"name\":\"is_alarm\",\"value\":\"true\"}]", 
                    "Unit": "Count/Second", 
                    "Statistics": "Average", 
                    "Namespace": "acs_slb_dashboard"
                }, 
                {
                    "MetricName": "InstanceStatusCode3xx", 
                    "Periods": "60,300", 
                    "Description": "", 
                    "Dimensions": "userId,instanceId", 
                    "Labels": "[{\"name\":\"alertUnit\",\"value\":\"Count/Second\"},{\"name\":\"minAlertPeriod\",\"value\":\"60\"},{\"name\":\"metricCategory\",\"value\":\"instanceId\"},{\"name\":\"is_alarm\",\"value\":\"true\"}]", 
                    "Unit": "Count/Second", 
                    "Statistics": "Average", 
                    "Namespace": "acs_slb_dashboard"
                }, 
                {
                    "MetricName": "InstanceStatusCode4xx", 
                    "Periods": "60,300", 
                    "Description": "", 
                    "Dimensions": "userId,instanceId", 
                    "Labels": "[{\"name\":\"alertUnit\",\"value\":\"Count/Second\"},{\"name\":\"minAlertPeriod\",\"value\":\"60\"},{\"name\":\"metricCategory\",\"value\":\"instanceId\"},{\"name\":\"is_alarm\",\"value\":\"true\"}]", 
                    "Unit": "Count/Second", 
                    "Statistics": "Average", 
                    "Namespace": "acs_slb_dashboard"
                }, 
                {
                    "MetricName": "InstanceStatusCode5xx", 
                    "Periods": "60,300", 
                    "Description": "", 
                    "Dimensions": "userId,instanceId", 
                    "Labels": "[{\"name\":\"alertUnit\",\"value\":\"Count/Second\"},{\"name\":\"minAlertPeriod\",\"value\":\"60\"},{\"name\":\"metricCategory\",\"value\":\"instanceId\"},{\"name\":\"is_alarm\",\"value\":\"true\"}]", 
                    "Unit": "Count/Second", 
                    "Statistics": "Average", 
                    "Namespace": "acs_slb_dashboard"
                }
            ]
        }, 
        "Code": 200, 
        "Success": true
    }

PutContact

You can call this operation to create an alert contact. If you have already added an alert contact, you can call this operation to modify the alert contact. For more information, see PutContact.

  1. In the request parameters, set the name and contact information of the alert contact.
    In this example, configure the following parameters and keep all other parameters as default:
    • ContactName: the name of the alert contact.
    • Channels.Mail: the Email address. After you add or modify an Email address, the recipient receives an Email that contains an activation link. The system adds the recipient to the list of alert contacts only after the recipient activates the Email address.

    Sample requests:

    http(s)://[Endpoint]/? Action=PutContact
    &ContactName=doctest
    &Channels.Mail=test@example.com
    &<Common request parameters>
  2. Check whether the alert contact is created successfully based on the returned parameters.
    Sample responses:
    {
        "RequestId": "50E26BC3-B211-4713-9608-EE8CE2EAB7E1", 
        "Code": "200", 
        "Success": true
    }

PutContactGroup

You can call this operation to create an alert contact group, and modify the existing alert contact group. For more information, see PutContactGroup.

  1. In the request parameters, set the name and description of an alert contact group, and the names of the alert contacts in the group.
    In this example, configure the following parameters and keep all other parameters as default:
    • ContactGroupName: the name of the alert contact group.
    • Describe: the description of the alert contact group.
    • ContactNames: the names of the alert contacts in the group.

    Sample requests:

    http(s)://[Endpoint]/? Action=PutContactGroup
    &ContactGroupName=doctestgroup
    &ContactNames.1=doctest
    &Describe=SLB alert contact group
    &<Common request parameters>
  2. Check whether the alert contact group is successfully created based on the returned parameters.
    Sample responses:
    {
        "RequestId": "B8B88837-99A4-4F0D-B445-5E9C072D154D", 
        "Code": "200", 
        "Success": true
    }

PutResourceMetricRule

You can call this operation to configure an alert rule for a performance metric of a resource. For more information, see PutResourceMetricRule.

  1. In the request parameters, set the alert threshold for the number of abnormal ECS instances.
    In this example, configure the following parameters and keep all other parameters as default:
    Parameter Description
    RuleId The ID of the alert rule.
    Namespace Set the Namespace of SLB to acs_slb_dashboard.
    MetricName The names of monitoring metrics. You can query the result according to DescribeMetricMetaList or set the parameter according to Monitoring and alerting metrics.

    In this example, the metric that indicates the number of abnormal ECS instances is UnhealthyServerCount.

    Resources The resources to be associated with the alert rules. If you want to associate SLB instances with the alert rule, specify the instances in the format of [{"instanceId":"lb-bp1rbwvouu******"}].
    ContactGroups The alert contact group. Multiple groups must be separated with commas (,).
    Escalations.Critical.Statistics The method used to collect statistics about critical alerts. Valid values:
    • Average: the average value.
    • Minimum: the minimum value.
    • Maximum: the maximum value.
    Escalations.Critical.ComparisonOperator The comparison operator of the threshold for critical alerts. Valid values:
    • GreaterThanOrEqualToThreshold: greater than or equal to the threshold.
    • GreaterThanThreshold: greater than the threshold.
    • LessThanOrEqualToThreshold: less than or equal to the threshold.
    • LessThanThreshold: less than the threshold.
    • NotEqualToThreshold: not equal to the threshold.
    • GreaterThanYesterday: greater than that of the same time period yesterday.
    • LessThanYesterday: less than that of the same time period yesterday.
    • GreaterThanLastWeek: greater than that of the same time period last week.
    • LessThanLastWeek: less than that of the same time period last week.
    • GreaterThanLastPeriod: greater than that of the last statistical period.
    • LessThanLastPeriod: less than that of the last statistical period.
    Escalations.Critical.Threshold The threshold for triggering critical alerts.
    Escalations.Critical.Times The number of times for which the metric value consecutively exceeds the threshold before a critical alert is triggered.
    Escalations.Warn.Statistics The method used to collect statistics about warn alerts. Valid values:
    • Average: the average value.
    • Minimum: the minimum value.
    • Maximum: the maximum value.
    Escalations.Warn.ComparisonOperator The comparison operator of the threshold for warn alerts. Valid values:
    • GreaterThanOrEqualToThreshold: greater than or equal to the threshold.
    • GreaterThanThreshold: greater than the threshold.
    • LessThanOrEqualToThreshold: less than or equal to the threshold.
    • LessThanThreshold: less than the threshold.
    • NotEqualToThreshold: not equal to the threshold.
    • GreaterThanYesterday: greater than that of the same time period yesterday.
    • LessThanYesterday: less than that of the same time period yesterday.
    • GreaterThanLastWeek: greater than that of the same time period last week.
    • LessThanLastWeek: less than that of the same time period last week.
    • GreaterThanLastPeriod: greater than that of the last statistical period.
    • LessThanLastPeriod: less than that of the last statistical period.
    Escalations.Warn.Threshold The threshold for triggering warn alerts.
    Escalations.Warn.Times The number of times for which the metric value consecutively exceeds the threshold before a warn alert is triggered.
    Escalations.Info.Statistics The method used to collect statistics about info alerts. Valid values:
    • Average: the average value.
    • Minimum: the minimum value.
    • Maximum: the maximum value.
    Escalations.Info.ComparisonOperator The comparison operator of the threshold for info alerts. Valid values:
    • GreaterThanOrEqualToThreshold: greater than or equal to the threshold.
    • GreaterThanThreshold: greater than the threshold.
    • LessThanOrEqualToThreshold: less than or equal to the threshold.
    • LessThanThreshold: less than the threshold.
    • NotEqualToThreshold: not equal to the threshold.
    • GreaterThanYesterday: greater than that of the same time period yesterday.
    • LessThanYesterday: less than that of the same time period yesterday.
    • GreaterThanLastWeek: greater than that of the same time period last week.
    • LessThanLastWeek: less than that of the same time period last week.
    • GreaterThanLastPeriod: greater than that of the last statistical period.
    • LessThanLastPeriod: less than that of the last statistical period.
    Escalations.Info.Threshold The threshold for triggering info alerts.
    Escalations.Info.Times The number of times for which the metric value consecutively exceeds the threshold before an info alert is triggered.

    Sample requests:

    http(s)://[Endpoint]/? Action=PutResourceMetricRule
    &ContactGroups=doctestgroup
    &MetricName=UnhealthyServerCount
    &Namespace=acs_slb_dashboard
    &Resources=[{"instanceId":"lb-bp1rbwvouuyipbc*****}]
    &Escalations.Critical.Statistics=Minimum
    &Escalations.Critical.ComparisonOperator=GreaterThanOrEqualToThreshold
    &Escalations.Critical.Threshold=100
    &Escalations.Warn.Statistics=Average
    &Escalations.Warn.ComparisonOperator=GreaterThanOrEqualToThreshold
    &Escalations.Warn.Threshold=30
    &Escalations.Info.Statistics=Maximum
    &Escalations.Info.ComparisonOperator=30
    &Escalations.Info.Threshold=30
    &<Common request parameters>
  2. Check whether the alert rule is successfully created based on the returned Success value.
    Sample responses:
    {
        "Message":"",
        "RequestId":"C65B0B84-DDE8-4DCA-8663-5836773102D4",
        "Success":true,
        "Code":"200"
    }

DescribeMetricRuleList

You can call this operation to query a list of alert rules. For more information, see DescribeMetricRuleList.

  1. In the request parameters, specify the SLB namespace and alert metrics to retrieve detailed information about the alert metrics.
    In this example, configure the following parameters and keep all other parameters as default:
    • Namespace: Set the namespace of SLB to acs_slb_dashboard.
    • MetricName: Specify the alert metrics to be queried.
    Request parameters:
    http(s)://[Endpoint]/? Action=DescribeMetricRuleList
    &Namespace=acs_slb_dashboard
    &MetricName=UnhealthyServerCount
    &<Common request parameters>
  2. View the details of the alert metrics specified in this example based on the returned parameters.
    Sample responses:
    {
        "RequestId": "F249E314-1763-4662-A347-BD54C739191E", 
        "Total": 1, 
        "Alarms":{
            "Alarm":[
                {
                    "GroupName": "" 
                    "SilenceTime": 86400, 
                    "ContactGroups": "doctestgroup", 
                    "NoEffectiveInterval": "", 
                    "MailSubject": "${serviceType}-${metricName}-${levelDescription} notification (${dimensions})", 
                    "RuleId": "123", 
                    "SourceType": "METRIC", 
                    "Period": 300, 
                    "Dimensions": "", 
                    "EffectiveInterval": "", 
                    "Namespace": "acs_slb_dashboard", 
                    "AlertState": "INSUFFICIENT_DATA", 
                    "GroupId": "", 
                    "MetricName": "UnhealthyServerCount", 
                    "EnableState": true, 
                    "Escalations": {
                        "Critical": { }, 
                        "Info": {
                            "ComparisonOperator": "LessThanThreshold", 
                            "Times": 3, 
                            "Statistics": "Average", 
                            "Threshold": "3"
                        }, 
                        "Warn": {
                            "ComparisonOperator": "GreaterThanThreshold", 
                            "Times": 3, 
                            "Statistics": "Average", 
                            "Threshold": "10"
                        }
                    }, 
                    "Webhook": "", 
                    "Resources": "[{\"instanceId\":\"lb-bp1rbwvouuyipbcs9877l\"}]", 
                    "RuleName": "UnhealthyServerCount"
                }
            ]
        }, 
        "Code": "200", 
        "Success": true
    }