介绍如何通过云监控Java和Python SDK查看负载均衡实例的监控项和详细监控数据。

前提条件

已知负载均衡在云监控中设置报警的产品标签SLB。

背景信息

通过SDK查看监控数据API使用流程,如下图所示。

流程

流程说明如下:

  1. 调用DescribeProjectMeta接口查询云监控中负载均衡的数据命名空间Namespace。
  2. 调用DescribeMetricMetaList接口查询云监控开放的时序类指标监控项描述。
  3. 查看监控项。
    • 调用DescribeMetricLast接口查询负载均衡指定监控对象的最新监控数据。
    • 调用DescribeMetricList接口查询负载均衡指定时间段内监控对象的时序指标监控数据。

Python

示例:查询实例ID为lb-f8zbff0i07sv4qr1****,已配置七层监听的负载均衡实例的Qps监控项。

Python SDK代码如下:

from aliyunsdkcms.request.v20190101 import DescribeProjectMetaRequest, DescribeMetricMetaListRequest, \
    DescribeMetricLastRequest, DescribeMetricListRequest
from aliyunsdkcore.client import AcsClient
import json

if __name__ == '__main__':
    # 1.初始化SDK
    ACS_CLIENT = AcsClient(
        'LTAI4FicM86BTPDyP******',  # your-access-key-id
        'VRj7d6LOl2ZyFyfYTWYzGk0*****',  # your-access-key-secret
        'cn-heyuan',  # your-region-id
    )

    # 过滤标签,此处过滤产品名称为SLB的数据
    labels = "[{\"name\":\"product\",\"value\":\"SLB\"}]"
    # 监控维度,此处查询后端服务器实例的监控数据
    dimensions = "[{\"instanceId\":\"lb-f8zbff0i07sv4qr1******\"}]"
    # 指定查询时间段,根据需要自行替换
    startTime = "2020-04-08 11:39:30"
    endTime = "2020-04-08 11:50:30"
    # 监控数据时间间隔
    period = "60"

    # 2.调用DescribeProjectMeta接口查询SLB的Namespace
    describeProjectMetaRequest = DescribeProjectMetaRequest.DescribeProjectMetaRequest()
    describeProjectMetaRequest.set_Labels(labels)
    describeProjectMetaResponse = ACS_CLIENT.do_action_with_exception(describeProjectMetaRequest)
    describeProjectMetaResponse_json = json.loads(describeProjectMetaResponse)
    namespace = describeProjectMetaResponse_json['Resources']['Resource'][0]['Namespace']
    print("SLB Namespace: ", namespace)

    # 3.调用DescribeMetricMetaList接口查询SLB可用的云监控时序类指标监控项
    describeMetricMetaListRequest = DescribeMetricMetaListRequest.DescribeMetricMetaListRequest()
    describeMetricMetaListRequest.set_Namespace(namespace)
    describeMetricMetaListRequest.set_PageSize(100)
    describeMetricMetaListResponse = ACS_CLIENT.do_action_with_exception(describeMetricMetaListRequest)
    describeMetricMetaListResponse_json = json.loads(describeMetricMetaListResponse)
    metricMetaListResources = describeMetricMetaListResponse_json['Resources']['Resource']
    print(metricMetaListResources)

    # 这里以查询此监控项为例:ActiveConnection(端口当前活跃连接数)
    metricName = "Qps"  #设置监控项

    # 4.查询指定监控项的最新监控数据
    describeMetricLastRequest = DescribeMetricLastRequest.DescribeMetricLastRequest()
    describeMetricLastRequest.set_Namespace(namespace)
    describeMetricLastRequest.set_MetricName(metricName)
    describeMetricLastRequest.set_Dimensions(dimensions)
    describeMetricLastRequest.set_Period(period)
    describeMetricLastResponse = ACS_CLIENT.do_action_with_exception(describeMetricLastRequest)
    describeMetricLastResponse_json = json.loads(describeMetricLastResponse)
    print("最新监控数据:\n", describeMetricLastResponse_json['Datapoints'])

    # 5.查询指定时间段内的指定监控项数据
    describeMetricListRequest = DescribeMetricListRequest.DescribeMetricListRequest()
    describeMetricListRequest.set_Namespace(namespace)
    describeMetricListRequest.set_MetricName(metricName)
    describeMetricListRequest.set_Dimensions(dimensions)
    describeMetricListRequest.set_Period(period)
    describeMetricListRequest.set_StartTime(startTime)
    describeMetricListRequest.set_EndTime(endTime)
    describeMetricListResponse = ACS_CLIENT.do_action_with_exception(describeMetricListRequest)
    print(describeMetricListResponse)
    describeMetricListResponse_json = json.loads(describeMetricListResponse)
    print(describeMetricListResponse_json)
    print("指定时间段的监控数据:\n", describeMetricListResponse_json['Datapoints'])
			

Java

示例:查询实例ID为lb-f8zbff0i07sv4qr1****,已配置七层监听的负载均衡实例的Qps监控项。

Java SDK代码如下:

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.List;

public class DescribeSLBMonitorData {

    public static void main(String[] args) {
        // 1.初始化SDK
        DefaultProfile profile = DefaultProfile.getProfile(
                "cn-hangzhou",// 地域ID
                CommonConfig.ACCESSKEY_ID,// 您的AccessKey ID
                CommonConfig.ACCESSKEY_SECRET);// 您的AccessKey Secret
        IAcsClient client = new DefaultAcsClient(profile);

        Gson gson = new Gson();
        // 过滤标签,此处过滤产品名称为SLB的数据
        String labels = "[{\"name\":\"product\",\"value\":\"SLB\"}]";
        // 监控维度,此处查询SLB实例的监控数据
        String dimensions = "[{\"instanceId\":\"lb-f8zbff0i07sv4qr1******\"}]";
        // 指定查询时间段,根据需要自行替换
        String startTime = "2020-04-08 11:39:30";
        String endTime = "2020-04-08 11:50:30";
        // 监控数据时间间隔
        String period = "60";
        DescribeSLBMonitorData describeSLBMonitorData = new DescribeSLBMonitorData();

        // 2.调用DescribeProjectMeta接口查询SLB的Namespace
        DescribeProjectMetaRequest describeProjectMetaRequest = new DescribeProjectMetaRequest();
        describeProjectMetaRequest.setLabels(labels);
        DescribeProjectMetaResponse describeProjectMetaResponse = describeSLBMonitorData.describeProjectMeta(describeProjectMetaRequest, client);
        DescribeProjectMetaResponse.Resource projectMetaResource = describeProjectMetaResponse.getResources().get(0);
        String namespace = projectMetaResource.getNamespace();
        System.out.printf("SLB Namespace: %s\n", namespace);

        // 3.调用DescribeMetricMetaList接口查询SLB可用的云监控时序类指标监控项
        DescribeMetricMetaListRequest describeMetricMetaListRequest = new DescribeMetricMetaListRequest();
        describeMetricMetaListRequest.setNamespace(namespace);
        describeMetricMetaListRequest.setPageSize(100);
        DescribeMetricMetaListResponse describeMetricMetaListResponse = describeSLBMonitorData.describeMetricMetaList(describeMetricMetaListRequest, client);
        List<DescribeMetricMetaListResponse.Resource> metricMetaListResources = describeMetricMetaListResponse.getResources();
        System.out.println(gson.toJson(metricMetaListResources));

        // 这里以查询此监控项为例:ActiveConnection(端口当前活跃连接数)
        String metricName = "Qps";  //设置监控项

        // 4.查询指定监控项的最新监控数据
        DescribeMetricLastRequest describeMetricLastRequest = new DescribeMetricLastRequest();
        describeMetricLastRequest.setNamespace(namespace);
        describeMetricLastRequest.setMetricName(metricName);
        describeMetricLastRequest.setDimensions(dimensions);
        describeMetricLastRequest.setPeriod(period);
        DescribeMetricLastResponse describeMetricLastResponse = describeSLBMonitorData.describeMetricLast(describeMetricLastRequest, client);
        System.out.printf("最新监控数据:\n%s", describeMetricLastResponse.getDatapoints());

        // 5.查询指定时间段内的指定监控项数据
        DescribeMetricListRequest describeMetricListRequest = new DescribeMetricListRequest();
        describeMetricListRequest.setNamespace(namespace);
        describeMetricListRequest.setMetricName(metricName);
        describeMetricListRequest.setDimensions(dimensions);
        describeMetricListRequest.setPeriod(period);
        describeMetricListRequest.setStartTime(startTime);
        describeMetricListRequest.setEndTime(endTime);
        DescribeMetricListResponse describeMetricListResponse = describeSLBMonitorData.describeMetricList(describeMetricListRequest, client);
        System.out.printf("\n指定时间段的监控数据:\n%s", describeMetricListResponse.getDatapoints());
    }

    /**
     * 获取接入的云产品信息,包括产品的描述信息、 Namespace和标签
     */
    private DescribeProjectMetaResponse describeProjectMeta(DescribeProjectMetaRequest request, IAcsClient client) {
        try {
            // 调用SDK发送请求
            return client.getAcsResponse(request);
        } catch (ClientException e) {
            e.printStackTrace();
            // 发生调用错误,抛出运行时异常
            throw new RuntimeException();
        }
    }

    /**
     * 查询指定监控对象的最新监控数据
     */
    private DescribeMetricLastResponse describeMetricLast(DescribeMetricLastRequest request, IAcsClient client) {
        try {
            // 调用SDK发送请求
            return client.getAcsResponse(request);
        } catch (ClientException e) {
            e.printStackTrace();
            // 发生调用错误,抛出运行时异常
            throw new RuntimeException();
        }
    }

    /**
     * 查询云监控开放的时序类指标
     */
    private DescribeMetricMetaListResponse describeMetricMetaList(DescribeMetricMetaListRequest request, IAcsClient client) {
        try {
            // 调用SDK发送请求
            return client.getAcsResponse(request);
        } catch (ClientException e) {
            e.printStackTrace();
            // 发生调用错误,抛出运行时异常
            throw new RuntimeException();
        }
    }

    /**
     * 查询指定时间段内的云产品时序指标监控数据
     */
    private DescribeMetricListResponse describeMetricList(DescribeMetricListRequest request, IAcsClient client) {
        try {
            // 调用SDK发送请求
            return client.getAcsResponse(request);
        } catch (ClientException e) {
            e.printStackTrace();
            // 发生调用错误,抛出运行时异常
            throw new RuntimeException();
        }
    }

}

返回结果

SDK返回结果如下:

SLB  Namespace:    acs_slb_dashboard     
[{'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'}, {'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': '端口当前新建连接数', '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': '端口每秒流入数据包数', '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': '端口每秒流出数据包数', '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': '端口每秒流入数据量', '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': '端口每秒流出数据量', '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': '当前后端异常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': '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'}]
最新监控数据:
 [{"timestamp":1586318940000,"userId":"18576685985*****","instanceId":"lb-f8zbff0i07sv4qr1*****","port":"8090","protocol":"http","vip":"47.115.**.**","Average":0}]
b'{"RequestId":"16064EB5-909D-40E3-BB9B-AB287E801AB1","Period":"60","Datapoints":"[{\\"timestamp\\":1586317200000,\\"userId\\":\\"18576685985*****\\",\\"instanceId\\":\\"lb-f8zbff0i07sv4qr******\\",\\"port\\":\\"80\\",\\"protocol\\":\\"http\\",\\"vip\\":\\"47.115.**.**\\",\\"Average\\":0},{\\"timestamp\\":1586317260000,\\"userId\\":\\"18576685985*****\\",\\"instanceId\\":\\"lb-f8zbff0i07sv4qr1*****\\",\\"port\\":\\"80\\",\\"protocol\\":\\"http\\",\\"vip\\":\\"47.115.**.**\\",\\"Average\\":0},{\\"timestamp\\":1586317320000,\\"userId\\":\\"18576685985*****\\",\\"instanceId\\":\\"lb-f8zbff0i07sv4qr1*****\\",\\"port\\":\\"80\\",\\"protocol\\":\\"http\\",\\"vip\\":\\"47.115.**.**\\",\\"Average\\":0},{\\"timestamp\\":1586317380000,\\"userId\\":\\"18576685985*****\\",\\"instanceId\\":\\"lb-f8zbff0i07sv4qr1*****\\",\\"port\\":\\"80\\",\\"protocol\\":\\"http\\",\\"vip\\":\\"47.115.**.**\\",\\"Average\\":0},{\\"timestamp\\":1586317440000,\\"userId\\":\\"18576685985*****\\",\\"instanceId\\":\\"lb-f8zbff0i07sv4qr1*****\\",\\"port\\":\\"8090\\",\\"protocol\\":\\"http\\",\\"vip\\":\\"47.115.**.**\\",\\"Average\\":0},{\\"timestamp\\":1586317500000,\\"userId\\":\\"18576685985*****\\",\\"instanceId\\":\\"lb-f8zbff0i07sv4qr1*****\\",\\"port\\":\\"8090\\",\\"protocol\\":\\"http\\",\\"vip\\":\\"47.115.**.**\\",\\"Average\\":0},{\\"timestamp\\":1586317560000,\\"userId\\":\\"18576685985*****\\",\\"instanceId\\":\\"lb-f8zbff0i07sv4qr1*****\\",\\"port\\":\\"8090\\",\\"protocol\\":\\"http\\",\\"vip\\":\\"47.115.**.**\\",\\"Average\\":0},{\\"timestamp\\":1586317620000,\\"userId\\":\\"18576685985*****\\",\\"instanceId\\":\\"lb-f8zbff0i07sv4qr1*****\\",\\"port\\":\\"8090\\",\\"protocol\\":\\"http\\",\\"vip\\":\\"47.115.**.**\\",\\"Average\\":0},{\\"timestamp\\":1586317680000,\\"userId\\":\\"18576685985*****\\",\\"instanceId\\":\\"lb-f8zbff0i07sv4qr1*****\\",\\"port\\":\\"8090\\",\\"protocol\\":\\"http\\",\\"vip\\":\\"47.115.**.**\\",\\"Average\\":0},{\\"timestamp\\":1586317740000,\\"userId\\":\\"18576685985*****\\",\\"instanceId\\":\\"lb-f8zbff0i07sv4qr1*****\\",\\"port\\":\\"8090\\",\\"protocol\\":\\"http\\",\\"vip\\":\\"47.115.**.**\\",\\"Average\\":0},{\\"timestamp\\":1586317800000,\\"userId\\":\\"18576685985*****\\",\\"instanceId\\":\\"lb-f8zbff0i07sv4qr1*****\\",\\"port\\":\\"8090\\",\\"protocol\\":\\"http\\",\\"vip\\":\\"47.115.**.**\\",\\"Average\\":0}]","Code":"200","Success":true}'
{'RequestId': '16064EB5-909D-40E3-BB9B-AB287E801AB1', 'Period': '60', 'Datapoints': '[{"timestamp":1586317200000,"userId":"1857668598503****","instanceId":"lb-f8zbff0i07sv4qr1******","port":"80","protocol":"http","vip":"47.115.**.**","Average":0},{"timestamp":1586317260000,"userId":"185766859850****","instanceId":"lb-f8zbff0i07sv4qr1****","port":"80","protocol":"http","vip":"47.115.**.**","Average":0},{"timestamp":1586317320000,"userId":"18576685985*****","instanceId":"lb-f8zbff0i07sv4qr1*****","port":"80","protocol":"http","vip":"47.115.**.**","Average":0},{"timestamp":1586317380000,"userId":"18576685985*****","instanceId":"lb-f8zbff0i07sv4qr1*****","port":"80","protocol":"http","vip":"47.115.**.**","Average":0},{"timestamp":1586317440000,"userId":"18576685985*****","instanceId":"lb-f8zbff0i07sv4qr1*****","port":"8090","protocol":"http","vip":"47.115.**.**","Average":0},{"timestamp":1586317500000,"userId":"18576685985*****","instanceId":"lb-f8zbff0i07sv4qr1*****","port":"8090","protocol":"http","vip":"47.115.**.**","Average":0},{"timestamp":1586317560000,"userId":"18576685985*****","instanceId":"lb-f8zbff0i07sv4qr1*****","port":"8090","protocol":"http","vip":"47.115.**.**","Average":0},{"timestamp":1586317620000,"userId":"18576685985*****","instanceId":"lb-f8zbff0i07sv4qr1*****","port":"8090","protocol":"http","vip":"47.115.**.**","Average":0},{"timestamp":1586317680000,"userId":"18576685985*****","instanceId":"lb-f8zbff0i07sv4qr1*****","port":"8090","protocol":"http","vip":"47.115.**.**","Average":0},{"timestamp":1586317740000,"userId":"18576685985*****","instanceId":"lb-f8zbff0i07sv4qr1*****","port":"8090","protocol":"http","vip":"47.115.**.**","Average":0},{"timestamp":1586317800000,"userId":"18576685985*****","instanceId":"lb-f8zbff0i07sv4qr1*****","port":"8090","protocol":"http","vip":"47.115.**.**","Average":0}]', 'Code': '200', 'Success': True}
指定时间段的监控数据:
 [{"timestamp":1586317200000,"userId":"18576685985*****","instanceId":"lb-f8zbff0i07sv4qr1q****","port":"80","protocol":"http","vip":"47.115.**.**","Average":0},{"timestamp":1586317260000,"userId":"18576685985*****","instanceId":"lb-f8zbff0i07sv4qr1*****","port":"80","protocol":"http","vip":"47.115.**.**","Average":0},{"timestamp":1586317320000,"userId":"18576685985*****","instanceId":"lb-f8zbff0i07sv4qr1*****","port":"80","protocol":"http","vip":"47.115.**.**","Average":0},{"timestamp":1586317380000,"userId":"18576685985*****","instanceId":"lb-f8zbff0i07sv4qr1*****","port":"80","protocol":"http","vip":"47.115.**.**","Average":0},{"timestamp":1586317440000,"userId":"18576685985*****","instanceId":"lb-f8zbff0i07sv4qr1*****","port":"8090","protocol":"http","vip":"47.115.**.**","Average":0},{"timestamp":1586317500000,"userId":"18576685985*****","instanceId":"lb-f8zbff0i07sv4qr1*****","port":"8090","protocol":"http","vip":"47.115.**.**","Average":0},{"timestamp":1586317560000,"userId":"18576685985*****","instanceId":"lb-f8zbff0i07sv4qr1*****","port":"8090","protocol":"http","vip":"47.115.**.**","Average":0},{"timestamp":1586317620000,"userId":"18576685985*****","instanceId":"lb-f8zbff0i07sv4qr1*****","port":"8090","protocol":"http","vip":"47.115.**.**","Average":0},{"timestamp":1586317680000,"userId":"18576685985*****","instanceId":"lb-f8zbff0i07sv4qr1*****","port":"8090","protocol":"http","vip":"47.115.**.**","Average":0},{"timestamp":1586317740000,"userId":"18576685985*****","instanceId":"lb-f8zbff0i07sv4qr1*****","port":"8090","protocol":"http","vip":"47.115.**.**","Average":0},{"timestamp":1586317800000,"userId":"18576685985*****","instanceId":"lb-f8zbff0i07sv4qr1*****","port":"8090","protocol":"http","vip":"47.115.**.**","Average":0}]