This topic describes how to call the CloudMonitor SDK 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 for setting alert rules by calling the CloudMonitor SDK.

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.

Python

For example, a TCP listener has been configured for the lb-bp13hithhod4aoxc***** 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.

from aliyunsdkcms.request.v20190101 import DescribeMetricMetaListRequest, PutContactRequest, PutContactGroupRequest, \
    PutResourceMetricRuleRequest, DescribeMetricRuleListRequest
from aliyunsdkcore.client import AcsClient
import json, uuid

if __name__ == '__main__':
    # 1. Initialize the SDK
    ACS_CLIENT = AcsClient(
        'LTAI4FicM86BTPDyP*****',  # your-access-key-id
        'VRj7d6LOl2ZyFyfYTWYzGk0e*****',  # your-access-key-secret
        'cn-hangzhou',  # your-region-id
    )

    # The namespace
    namespace = "acs_slb_dashboard"

    # 2. Query the descriptions of time series metrics that are supported in CloudMonitor
    describeMetricMetaListRequest = DescribeMetricMetaListRequest.DescribeMetricMetaListRequest()
    # Set the namespace
    describeMetricMetaListRequest.set_Namespace(namespace)
    # The number of records on each page. Default value: 30.
    describeMetricMetaListRequest.set_PageSize(100)
    describeMetricMetaListResponse = ACS_CLIENT.do_action_with_exception(describeMetricMetaListRequest)
    print(json.loads(describeMetricMetaListResponse))

    # 3. Create an alert contact
    putContactRequest = PutContactRequest.PutContactRequest()
    # The name of the alert contact that you want to create
    putContactRequest.set_ContactName("doctest")
    # The description of the contact
    putContactRequest.set_Describe("doctest")
    # The email address of the contact
    putContactRequest.set_ChannelsMail("test@example.com")
    putContactResponse = ACS_CLIENT.do_action_with_exception(putContactRequest)
    print(json.loads(putContactResponse))

    # 4. Create an alert contact group
    putContactGroupRequest = PutContactGroupRequest.PutContactGroupRequest()
    # The name of the alert contact group that you want to create
    putContactGroupRequest.set_ContactGroupName("the default alert contact group")
    # The description of the alert contact group
    putContactGroupRequest.set_Describe("the default alert contact group")
    putContactGroupRequest.set_ContactNamess(["doctest"])
    putContactGroupResponse = ACS_CLIENT.do_action_with_exception(putContactGroupRequest)
    print(json.loads(putContactGroupResponse))

    # 5. Set an alert rule for a performance metric of a resource
    putResourceMetricRuleRequest = PutResourceMetricRuleRequest.PutResourceMetricRuleRequest()
    # The ID of the alert rule
    putResourceMetricRuleRequest.set_RuleId(uuid.uuid1())
    # The name of the alert rule
    putResourceMetricRuleRequest.set_RuleName("abnormal SLB instances")
    # The alert contact group. Multiple groups must be separated with commas (,).
    putResourceMetricRuleRequest.set_ContactGroups("the default alert contact group")
    # Set the namespace of SLB to acs_slb_dashboard
    putResourceMetricRuleRequest.set_Namespace(namespace)
    # The name of a monitoring metric. UnhealthyServerCount: the number of abnormal ECS instances.
    putResourceMetricRuleRequest.set_MetricName("UnhealthyServerCount")
    # The resources to be associated with the alert rules
    putResourceMetricRuleRequest.set_Resources("[{'instanceId':'lb-bp13hithhod*******'}]")

    # Set Critical alerts
    # The method used to collect statistics about Critical alerts. Average: average value.
    putResourceMetricRuleRequest.set_EscalationsCriticalStatistics("Average")
    # The comparison operator of the threshold for Critical alerts. GreaterThanOrEqualToThreshold: greater than or equal to the threshold.
    putResourceMetricRuleRequest.set_EscalationsCriticalComparisonOperator("GreaterThanOrEqualToThreshold")
    # The threshold for triggering Critical alerts
    putResourceMetricRuleRequest.set_EscalationsCriticalThreshold("2")
    # The number of times for which the metric value consecutively exceeds the threshold before a Critical alert is triggered
    putResourceMetricRuleRequest.set_EscalationsCriticalTimes(5)

    # Set Info alerts
    # The method used to collect statistics about Info alerts. Average: average value.
    putResourceMetricRuleRequest.set_EscalationsInfoStatistics("Average")
    # The comparison operator of the threshold for Info alerts. GreaterThanOrEqualToThreshold: greater than or equal to the threshold.
    putResourceMetricRuleRequest.set_EscalationsInfoComparisonOperator("GreaterThanOrEqualToThreshold")
    # The threshold for triggering Info alerts
    putResourceMetricRuleRequest.set_EscalationsInfoThreshold("1")
    # The number of times for which the metric value consecutively exceeds the threshold before an Info alert is triggered
    putResourceMetricRuleRequest.set_EscalationsInfoTimes(5)

    # Set Warn alerts
    # The method used to collect statistics about Warn alerts. Average: average value.
    putResourceMetricRuleRequest.set_EscalationsWarnStatistics("Average")
    # The comparison operator of the threshold for Warn alerts. GreaterThanOrEqualToThreshold: greater than or equal to the threshold.
    putResourceMetricRuleRequest.set_EscalationsWarnComparisonOperator("GreaterThanOrEqualToThreshold")
    # The threshold for triggering Warn alerts
    putResourceMetricRuleRequest.set_EscalationsWarnThreshold("1")
    # The number of times for which the metric value consecutively exceeds the threshold before a Warn alert is triggered
    putResourceMetricRuleRequest.set_EscalationsWarnTimes(5)

    putResourceMetricRuleResponse = ACS_CLIENT.do_action_with_exception(putResourceMetricRuleRequest)
    print(json.loads(putResourceMetricRuleResponse))

    # 6. Query the alert rules
    describeMetricRuleListRequest = DescribeMetricRuleListRequest.DescribeMetricRuleListRequest()
    # Set the namespace of SLB to acs_slb_dashboard
    describeMetricRuleListRequest.set_Namespace(namespace)
    # Set the alert metrics that you want to query
    describeMetricRuleListRequest.set_MetricName("UnhealthyServerCount")
    describeMetricRuleListResponse = ACS_CLIENT.do_action_with_exception(describeMetricRuleListRequest)
    print(json.loads(describeMetricRuleListResponse))
			

Java

For example, a TCP listener has been configured for the lb-bp13hithhod4aoxc***** 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.

package com.aliyun.cms;

import com.aliyun.CommonConfig;
import com.aliyuncs.DefaultAcsClient;
import com.aliyuncs.IAcsClient;
import com.aliyuncs.cms.model.v20190101.*;
import com.aliyuncs.exceptions.ClientException;
import com.aliyuncs.profile.DefaultProfile;
import com.google.gson.Gson;

import java.util.ArrayList;
import java.util.List;
import java.util.UUID;

public class CreateMetricRuleDemo {

    public static void main(String[] args) throws ClientException {
        // 1. Initialize the SDK
        DefaultProfile profile = DefaultProfile.getProfile(
                "cn-hangzhou",// The ID of the region
                CommonConfig.ACCESSKEY_ID,// Your AccessKey ID
                CommonConfig.ACCESSKEY_SECRET);// Your AccessKey secret
        IAcsClient client = new DefaultAcsClient(profile);

        // Namespace
        String namespace = "acs_slb_dashboard";
        Gson gson = new Gson();


        // 2. Query the descriptions of time series metrics that are supported in CloudMonitor
        DescribeMetricMetaListRequest describeMetricMetaListRequest = new DescribeMetricMetaListRequest();
        // Set the namespace
        describeMetricMetaListRequest.setNamespace(namespace);
        // The number of records on each page. Default value: 30.
        describeMetricMetaListRequest.setPageSize(100);
        DescribeMetricMetaListResponse describeMetricMetaListResponse = client.getAcsResponse(describeMetricMetaListRequest);
        System.out.println(gson.toJson(describeMetricMetaListResponse));


        // 3. Create an alert contact
        PutContactRequest putContactRequest = new PutContactRequest();
        // The name of the alert contact that you want to create
        putContactRequest.setContactName("doctest");
        // The description of the contact
        putContactRequest.setDescribe("doctest");
        // The email address of the contact
        putContactRequest.setChannelsMail("test@example.com");
        PutContactResponse putContactResponse = client.getAcsResponse(putContactRequest);
        System.out.println(gson.toJson(putContactResponse));


        // 4. Create an alert contact group
        PutContactGroupRequest putContactGroupRequest = new PutContactGroupRequest();
        // The name of the alert contact group that you want to create
        putContactGroupRequest.setContactGroupName("the default alert contact group");
        // The description of the alert contact group
        putContactGroupRequest.setDescribe("the default alert contact group");
        // The contacts in the alert contact group
        List<String> contactNames = new ArrayList<>();
        contactNames.add("doctest");
        putContactGroupRequest.setContactNamess(contactNames);
        PutContactGroupResponse putContactGroupResponse = client.getAcsResponse(putContactGroupRequest);
        System.out.println(gson.toJson(putContactGroupResponse));


        // 5. Set an alert rule for a performance metric of a resource
        PutResourceMetricRuleRequest putResourceMetricRuleRequest = new PutResourceMetricRuleRequest();
        // Generate a UUID with all lowercase letters without hyphen (-) as the unique ID of the alert rule
        String uuid = UUID.randomUUID().toString().replace("-", "").toLowerCase();
        // The ID of the alert rule
        putResourceMetricRuleRequest.setRuleId(uuid);
        // The name of the alert rule
        putResourceMetricRuleRequest.setRuleName("alert of abnormal SLB");
        // The alert contact group. Multiple groups must be separated with commas (,).
        putResourceMetricRuleRequest.setContactGroups("the default alert contact group");
        // Set the namespace of SLB to acs_slb_dashboard
        putResourceMetricRuleRequest.setNamespace(namespace);
        // The name of a monitoring metric. UnhealthyServerCount: the number of abnormal ECS instances.
        putResourceMetricRuleRequest.setMetricName("UnhealthyServerCount");
        // The resources to be associated with the alert rules
        putResourceMetricRuleRequest.setResources("[{\"instanceId\":\"lb-bp13hithhod4aoxc*****\"}]");

        // Set Critical alerts
        // The method used to collect statistics about Critical alerts. Average: average value.
        putResourceMetricRuleRequest.setEscalationsCriticalStatistics("Average");
        // The comparison operator of the threshold for Critical alerts. GreaterThanOrEqualToThreshold: greater than or equal to the threshold.
        putResourceMetricRuleRequest.setEscalationsCriticalComparisonOperator("GreaterThanOrEqualToThreshold");
         // The threshold for triggering Critical alerts
        putResourceMetricRuleRequest.setEscalationsCriticalThreshold("2");
        // The number of times for which the metric value consecutively exceeds the threshold before a Critical alert is triggered
        putResourceMetricRuleRequest.setEscalationsCriticalTimes(5);

        // Set Info alerts
        // The method used to collect statistics about Info alerts. Average: average value.
        putResourceMetricRuleRequest.setEscalationsInfoStatistics("Average");
        // The comparison operator of the threshold for Info alerts. GreaterThanOrEqualToThreshold: greater than or equal to the threshold.
        putResourceMetricRuleRequest.setEscalationsInfoComparisonOperator("GreaterThanOrEqualToThreshold");
         // The threshold for triggering Info alerts
        putResourceMetricRuleRequest.setEscalationsInfoThreshold("1");
        // The number of times for which the metric value consecutively exceeds the threshold before an Info alert is triggered
        putResourceMetricRuleRequest.setEscalationsInfoTimes(5);

        // Set Warn alerts
        // The method used to collect statistics about Warn alerts. Average: average value.
        putResourceMetricRuleRequest.setEscalationsWarnStatistics("Average");
        // The comparison operator of the threshold for Warn alerts. GreaterThanOrEqualToThreshold: greater than or equal to the threshold.
        putResourceMetricRuleRequest.setEscalationsWarnComparisonOperator("GreaterThanOrEqualToThreshold");
         // The threshold for triggering Warn alerts
        putResourceMetricRuleRequest.setEscalationsWarnThreshold("1");
        // The number of times for which the metric value consecutively exceeds the threshold before a Warn alert is triggered
        putResourceMetricRuleRequest.setEscalationsWarnTimes(5);
        PutResourceMetricRuleResponse putResourceMetricRuleResponse = client.getAcsResponse(putResourceMetricRuleRequest);
        System.out.println(gson.toJson(putResourceMetricRuleResponse));


        // 6. Query the alert rules
        DescribeMetricRuleListRequest describeMetricRuleListRequest = new DescribeMetricRuleListRequest();
        // Set the namespace of SLB to acs_slb_dashboard.
        describeMetricRuleListRequest.setNamespace(namespace);
        // Set the alert metrics that you want to query
        describeMetricRuleListRequest.setMetricName("UnhealthyServerCount");
        DescribeMetricRuleListResponse describeMetricRuleListResponse = client.getAcsResponse(describeMetricRuleListRequest);
        System.out.println(gson.toJson(describeMetricRuleListResponse));
    }
}
			

Response parameters

The parameters returned by the SDK are as follows:

{'TotalCount': 53, 'RequestId': '96E7FB37-8BD5-48C3-AE0C-CBC03F8B7FD7', 'Resources': {'Resource': [{'MetricName': 'ActiveConnection', 'Periods': '60,300', 'Description': 'the number of active connections on a 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': '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': 'the 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': 'the number of inactive connections on a 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,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': 'utilization of new connections', '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 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'}, {'MetricName': 'InstanceStatusCodeOther', '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': 'InstanceTrafficRX', 'Periods': '60,300', 'Description': '', 'Dimensions': 'userId,instanceId', 'Labels': '[{"name":"alertUnit","value":"Mbits/s"},{"name":"minAlertPeriod","value":"60"},{"name":"unitFactor","value":"1048576"},{"name":"metricCategory","value":"instanceId"},{"name":"is_alarm","value":"true"}]', 'Unit': 'bits/s', 'Statistics': 'Average,Minimum,Maximum', 'Namespace': 'acs_slb_dashboard'}, {'MetricName': 'InstanceTrafficTX', 'Periods': '60,300', 'Description': '', 'Dimensions': 'userId,instanceId', 'Labels': '[{"name":"alertUnit","value":"Mbits/s"},{"name":"minAlertPeriod","value":"60"},{"name":"unitFactor","value":"1048576"},{"name":"metricCategory","value":"instanceId"},{"name":"is_alarm","value":"true"}]', 'Unit': 'bits/s', 'Statistics': 'Average,Minimum,Maximum', 'Namespace': 'acs_slb_dashboard'}, {'MetricName': 'InstanceUpstreamCode4xx', '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': 'InstanceUpstreamCode5xx', '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': 'InstanceUpstreamRt', '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': 'MaxConnection', '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/Second', 'Statistics': 'Maximum,Minimum,Average', 'Namespace': 'acs_slb_dashboard'}, {'MetricName': 'NewConnection', 'Periods': '60,300', 'Description': 'number of new connections on a 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': 'PacketRX', 'Periods': '60,300', 'Description': 'the number of inbound packets over a port per second', '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': 'PacketTX', 'Periods': '60,300', 'Description': 'the number of outbound packets over a port per second', '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': 'Qps', 'Periods': '60,300', 'Description': '', 'Dimensions': 'userId,instanceId,port,protocol', 'Labels': '[{"name":"alertUnit","value":"Count/s"},{"name":"minAlertPeriod","value":"60"},{"name":"metricCategory","value":"port"},{"name":"is_alarm","value":"true"}]', 'Unit': 'Count/s', 'Statistics': 'Average', 'Namespace': 'acs_slb_dashboard'}, {'MetricName': 'Rt', 'Periods': '60,300', 'Description': '', 'Dimensions': 'userId,instanceId,port,protocol', 'Labels': '[{"name":"alertUnit","value":"ms"},{"name":"alertDefault","value":"ms"},{"name":"minAlertPeriod","value":"60"},{"name":"metricCategory","value":"port"},{"name":"is_alarm","value":"true"}]', 'Unit': '', 'Statistics': 'Average', 'Namespace': 'acs_slb_dashboard'}, {'MetricName': 'StatusCode2xx', 'Periods': '60,300', 'Description': '', 'Dimensions': 'userId,instanceId,port,protocol', 'Labels': '[{"name":"alertUnit","value":"Count/s"},{"name":"minAlertPeriod","value":"60"},{"name":"metricCategory","value":"port"},{"name":"is_alarm","value":"true"}]', 'Unit': 'Count/s', 'Statistics': 'Average', 'Namespace': 'acs_slb_dashboard'}, {'MetricName': 'StatusCode3xx', '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/Second', 'Statistics': 'Average', 'Namespace': 'acs_slb_dashboard'}, {'MetricName': 'StatusCode4xx', '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/Second', 'Statistics': 'Average', 'Namespace': 'acs_slb_dashboard'}, {'MetricName': 'StatusCode5xx', '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/Second', 'Statistics': 'Average', 'Namespace': 'acs_slb_dashboard'}, {'MetricName': 'StatusCodeOther', '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/Second', 'Statistics': 'Average', 'Namespace': 'acs_slb_dashboard'}, {'MetricName': 'TrafficRXNew', 'Periods': '60,300', 'Description': 'the amount of data received over a port per second', 'Dimensions': 'userId,instanceId,port,protocol', 'Labels': '[{"name":"alertUnit","value":"Mbits/s"},{"name":"minAlertPeriod","value":"60"},{"name":"unitFactor","value":"1048576"},{"name":"metricCategory","value":"port"},{"name":"is_alarm","value":"true"}]', 'Unit': 'bits/s', 'Statistics': 'Average,Minimum,Maximum', 'Namespace': 'acs_slb_dashboard'}, {'MetricName': 'TrafficTXNew', 'Periods': '60,300', 'Description': 'the amount of data sent over a port per second', 'Dimensions': 'userId,instanceId,port,protocol', 'Labels': '[{"name":"alertUnit","value":"Mbits/s"},{"name":"minAlertPeriod","value":"60"},{"name":"unitFactor","value":"1048576"},{"name":"metricCategory","value":"port"},{"name":"is_alarm","value":"true"}]', 'Unit': 'bits/s', 'Statistics': 'Average,Minimum,Maximum', 'Namespace': 'acs_slb_dashboard'}, {'MetricName': 'UnhealthyServerCount', 'Periods': '60,300', 'Description': 'the current number of abnormal 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': 'UpstreamCode4xx', 'Periods': '60,300', 'Description': '', 'Dimensions': 'userId,instanceId,port,protocol', 'Labels': '[{"name":"alertUnit","value":"Count/s"},{"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': 'UpstreamCode5xx', 'Periods': '60,300', 'Description': '', 'Dimensions': 'userId,instanceId,port,protocol', 'Labels': '[{"name":"alertUnit","value":"Count/s"},{"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': 'UpstreamRt', 'Periods': '60,300', 'Description': '', 'Dimensions': 'userId,instanceId,port,protocol', 'Labels': '[{"name":"alertUnit","value":"ms"},{"name":"minAlertPeriod","value":"60"},{"name":"metricCategory","value":"port"},{"name":"is_alarm","value":"true"}]', 'Unit': 'ms', 'Statistics': 'Average', 'Namespace': 'acs_slb_dashboard'}]}, 'Code': 200, 'Success': True}
{'RequestId': '653C4634-C32B-4858-B2BA-BAFC22DAF8FF', 'Code': '200', 'Success': True}
{'RequestId': '088D3BFF-DCED-4892-AE1D-468120BB6D74', 'Code': '200', 'Success': True}
{'Message': '', 'RequestId': '149A6CBC-1182-4749-8AD6-F55C563B9020', 'Code': 200, 'Success': True}
{'RequestId': '3E6ED37E-F5F3-472D-AF4D-8117329EAEC5', 'Total': 1, 'Alarms': {'Alarm': [{'GroupName': '', 'SilenceTime': 86400, 'ContactGroups': 'the default alert contact group', 'NoEffectiveInterval': '', 'MailSubject': '${serviceType}-${metricName}-${levelDescription}notification(${dimensions})', 'RuleId': 'edc0e1ae-7ef8-11ea-bf2d-54ee75d07c7c', 'SourceType': 'METRIC', 'Period': 300, 'Dimensions': '', 'EffectiveInterval': '', 'Namespace': 'acs_slb_dashboard', 'AlertState': 'OK', 'GroupId': '', 'MetricName': 'UnhealthyServerCount', 'EnableState': True, 'Escalations': {'Critical': {'ComparisonOperator': 'GreaterThanOrEqualToThreshold', 'Times': 5, 'Statistics': 'Average', 'Threshold': '2'}, 'Info': {'ComparisonOperator': 'GreaterThanOrEqualToThreshold', 'Times': 5, 'Statistics': 'Average', 'Threshold': '1'}, 'Warn': {'ComparisonOperator': 'GreaterThanOrEqualToThreshold', 'Times': 5, 'Statistics': 'Average', 'Threshold': '1'}}, 'Webhook': '', 'Resources': '[{"instanceId":"lb-bp13hithhod4aoxc*****"}]', 'RuleName': 'alert of abnormal SLB instances'}]}, 'Code': '200', 'Success': True}