介绍如何通过云监控API给负载均衡的监控项设置报警规则。

前提条件

  • 已知负载均衡在云监控中设置报警的产品标签SLB。
  • 已知云监控中负载均衡的数据命名空间Namespace为acs_slb_dashboard,获取方式请参见DescribeProjectMeta

背景信息

通过API设置报警规则的流程,如下图所示。

流程图

流程说明如下:

  1. 调用DescribeMetricMetaList查询云监控开放的SLB时序类指标监控项描述或直接查看监控项说明,详情参见监控报警项说明
  2. 调用PutContact创建或修改报警联系人信息。
  3. 调用PutContactGroup创建或者修改报警联系人组。
  4. 调用PutResourceMetricRule接口对单个资源的性能指标设置阈值报警规则。
  5. 调用DescribeMetricRuleList接口查询报警规则列表。

本文以给实例ID为lb-bp1rbwvouuyipbc***,已经配置了TCP监听的实例,创建后端异常ECS个数Critical、Warn和Info三种级别报警的阈值,超出阈值触发报警的规则。

DescribeMetricMetaList

调用DescribeMetricMetaList接口查询云监控开放的时序类指标监控项描述,详情请参见DescribeMetricMetaList

  1. 将请求参数中数据命名空间Namespace的值设置为acs_slb_dashboard,其他参数保持默认值。
    请求示例:
    http(s)://[Endpoint]/?Action=DescribeMetricMetaList
    &Namespace=acs_slb_dashboard
    &<公共请求参数>
  2. 根据返回参数,查看负载均衡的时序类指标监控项。可以查看本次示例中使用的监控项Qps是否存在。
    返回示例:
    {
        "TotalCount": 53, 
        "RequestId": "789846B4-56FC-4681-998C-5B7DBDFBE28F", 
        "Resources": {
            "Resource": [
                {
                    "MetricName": "ActiveConnection", 
                    "Periods": "60,300", 
                    "Description": "端口当前活跃连接数", 
                    "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": "Count/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_slb_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", 
                    "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": "HeathyServerCount", 
                    "Periods": "60,300", 
                    "Description": "当前后端健康ECS实例个数", 
                    "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": "端口当前非活跃连接数", 
                    "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": "最大连接数使用率", 
                    "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": "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": "新建连接数使用率", 
                    "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": "Count/s", 
                    "Statistics": "Average", 
                    "Namespace": "acs_slb_dashboard"
                }, 
                {
                    "MetricName": "InstanceQpsUtilization", 
                    "Periods": "60,300", 
                    "Description": "QPS使用率", 
                    "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

调用PutContact创建报警联系人,如果已有报警联系人,也可以通过该接口修改报警联系人,详情请参见PutContact

  1. 在请求参数中,设置报警联系人的姓名和联系方式。
    本示例中设置以下参数,其他参数保持默认值:
    • ContactName:自定义报警联系人姓名。
    • Channels.Mail:Email地址。添加或者修改Email会收到一个激活链接, 激活之后对应的Email才会被加到联系人中。

    请求示例:

    http(s)://[Endpoint]/?Action=PutContact
    &ContactName=doctest
    &Channels.Mail=test@example.com
    &<公共请求参数>
  2. 根据返回参数,判断报警联系人是否创建成功。
    返回示例:
    {
        "RequestId": "50E26BC3-B211-4713-9608-EE8CE2EAB7E1", 
        "Code": "200", 
        "Success": true
    }

PutContactGroup

调用PutContactGroup创建报警联系人组,如果已存在,也可以通过该接口修改报警联系人组,详情请参见PutContactGroup

  1. 在请求参数中,设置报警联系人组的名称、报警联系人组描述和报警联系人姓名。
    本示例中需要配置以下参数,其他参数保持默认值:
    • ContactGroupName:自定义报警联系人组名称。
    • Describe:报警联系组描述信息。
    • ContactNames:报警联系人名称。

    请求示例:

    http(s)://[Endpoint]/?Action=PutContactGroup
    &ContactGroupName=doctestgroup
    &ContactNames.1=doctest
    &Describe=slb报警人联系组
    &<公共请求参数>
  2. 根据返回参数,判断报警联系人组是否创建成功。
    返回示例:
    {
        "RequestId": "B8B88837-99A4-4F0D-B445-5E9C072D154D", 
        "Code": "200", 
        "Success": true
    }

PutResourceMetricRule

调用PutResourceMetricRule接口对单个资源的性能指标设置阈值报警规则,详情请参见PutResourceMetricRule

  1. 在请求参数中,设置本示例后端异常ECS个数的报警阈值。
    本示例需要设置以下参数,其他参数可以保持默认值。
    参数 参数说明
    RuleId 自定义报警规则ID。
    Namespace 设置负载均衡产品的数据命名空间acs_slb_dashboard
    MetricName 监控项名称,可根据DescribeMetricMetaList查询结果或监控报警项说明设置。

    本示例中后端异常ECS个数的监控项为UnhealthyServerCount

    Resources 需要报警的资源。负载均衡设置格式为[{"instanceId":"lb-bp1rbwvouu******"}]
    ContactGroups 报警联系人组,多个联系组之间用英文逗号分隔。
    Escalations.Critical.Statistics Critical级别报警统计方法,包括以下选项:
    • Average:平均值。
    • Minimum:最小值。
    • Maximum:最大值。
    Escalations.Critical.ComparisonOperator Critical级别阈值比较符。您可以根据以下规则进行选择:
    • GreaterThanOrEqualToThreshold:大于等于。
    • GreaterThanThreshold:大于。
    • LessThanOrEqualToThreshold:小于等于。
    • LessThanThreshold:小于。
    • NotEqualToThreshold:不等。
    • GreaterThanYesterday:同比昨天时间上涨。
    • LessThanYesterday:同比昨天时间下降。
    • GreaterThanLastWeek:同比上周同一时间上涨。
    • LessThanLastWeek:同比上周同一时间下降。
    • GreaterThanLastPeriod:环比上周期上涨。
    • LessThanLastPeriod:环比上周期下降。
    Escalations.Critical.Threshold Critical级别报警阈值。
    Escalations.Critical.Times Critical级别报警重试次数。
    Escalations.Warn.Statistics Warn级别报警统计方法,包含以下选项:
    • Average:平均值。
    • Minimum:最小值。
    • Maximum:最大值。
    Escalations.Warn.ComparisonOperator Warn级别阈值比较符。您可以根据以下规则进行选择:
    • GreaterThanOrEqualToThreshold:大于等于。
    • GreaterThanThreshold:大于。
    • LessThanOrEqualToThreshold:小于等于。
    • LessThanThreshold:小于。
    • NotEqualToThreshold:不等。
    • GreaterThanYesterday:同比昨天时间上涨。
    • LessThanYesterday:同比昨天时间下降。
    • GreaterThanLastWeek:同比上周同一时间上涨。
    • LessThanLastWeek:同比上周同一时间下降。
    • GreaterThanLastPeriod:环比上周期上涨。
    • LessThanLastPeriod:环比上周期下降。
    Escalations.Warn.Threshold Warn级别报警阈值。
    Escalations.Warn.Times Warn级别报警重试次数。
    Escalations.Info.Statistics Info级别报警统计方法,包含以下选项:
    • Average:平均值。
    • Minimum:最小值。
    • Maximum:最大值。
    Escalations.Info.ComparisonOperator Info级别阈值比较符。您可以根据以下规则进行选择:
    • GreaterThanOrEqualToThreshold:大于等于。
    • GreaterThanThreshold:大于。
    • LessThanOrEqualToThreshold:小于等于。
    • LessThanThreshold:小于。
    • NotEqualToThreshold:不等于。
    • GreaterThanYesterday:同比昨天时间上涨。
    • LessThanYesterday:同比昨天时间下降。
    • GreaterThanLastWeek:同比上周同一时间上涨。
    • LessThanLastWeek:同比上周同一时间下降。
    • GreaterThanLastPeriod:环比上周期上涨。
    • LessThanLastPeriod:环比上周期下降。
    Escalations.Info.Threshold Info级别报警阈值。
    Escalations.Info.Times Info级别报警重试次数。

    请求示例:

    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
    &<公共请求参数>
  2. 根据返回示例的Success值,判断报警规则是否创建成功。
    返回示例:
    {
        "Message":"",
        "RequestId":"C65B0B84-DDE8-4DCA-8663-5836773102D4",
        "Success":true,
        "Code":"200"
    }

DescribeMetricRuleList

调用DescribeMetricRuleList接口查询报警规则列表,详情请参见DescribeMetricRuleList

  1. 在请求参数中,设置负载均衡的数据命名空间和报警项,查看报警项详细信息。
    本示例需要设置以下参数,其他参数可以保持默认值:
    • Namespace:设置负载均衡的数据命名空间acs_slb_dashboard
    • MetricName:设置需要查询的报警项。
    请求参数:
    http(s)://[Endpoint]/?Action=DescribeMetricRuleList
    &Namespace=acs_slb_dashboard
    &MetricName=UnhealthyServerCount
    &<公共请求参数>
  2. 根据返回参数,查看本示例中设置的报警项详情。
    返回示例:
    {
        "RequestId": "F249E314-1763-4662-A347-BD54C739191E", 
        "Total": 1, 
        "Alarms": {
            "Alarm": [
                {
                    "GroupName": "", 
                    "SilenceTime": 86400, 
                    "ContactGroups": "doctestgroup", 
                    "NoEffectiveInterval": "", 
                    "MailSubject": "${serviceType}-${metricName}-${levelDescription}通知(${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-bp1rbwvouuyipbc*****\"}]", 
                    "RuleName": "UnhealthyServerCount"
                }
            ]
        }, 
        "Code": "200", 
        "Success": true
    }