百度智能云

All Product Document

          Cloud Monitor

          Query Latest Metric Data for Partial Dimensions

          API description

          Data from Cloud Product Monitor, Site Monitor, or Custom Monitor with a defined time range can be accessed using multiple dimensions, metrics, and statistics.

          API restriction

          • Each query can include up to 100 dimension combinations.
          • A query can include a maximum of 30 metric names.

          Request structure

          • Method: POST
          • URL: /csm/api/v2/userId/{userId}/services/{scope}/data/metricData/latest/batch

          Request parameters

          Name Types Description Required or not Parameter location
          userId String User ID Yes Body
          scope String Cloud product identifier. For values, refer to [Cloud Product Identifier List](BCM/Cloud Product Monitor List/Cloud Product Monitor Object Type List.md) Yes Body
          region String Region identifier. For values, refer to [Region List](BCM/API Reference/Service domain.md) Yes Body
          resourceType String Monitor object type, default value: Instance. For values, refer to [Cloud Product Monitor Object Type List](BCM/Cloud Product Monitor List/Cloud Product Monitor Object Type List.md) No Body
          metricNames List<String> List of Monitor Metrics Yes Body
          statistics List<String> List of statistic methods includes: average, maximum, minimum, sum, and sampleCount. If left empty, the latest original value will be returned by default. No Body
          dimensions List<Dimension> Dimension list No Body
          cycle int Statistical period, unit: second, default: 60, maximum: 3,600 No Body
          timestamp DateTime Time corresponding to the statistical period of Metric, default is the current time. Refer to [Date and Time](BCM/API Reference/General Description.md), expressed in UTC date Yes Body

          Dimension

          Name Types Description Required or not Parameter location
          name String Dimension key Yes Body
          value String Dimension value Yes Body

          Parameter explanation

          • For cloud product identifier like Scope, Metric, Statistic, and Dimension, refer to [Core Concepts](BCM/Product Description/Core concepts.md).

          Response parameters

          Name Types Description
          requestId String Request identifier
          code String Return code
          message String Error message
          metrics List<AllDataMetric> Monitor Metric

          AllDataMetric

          Name Types Description
          region String Region identifier
          scope String Cloud product identifier
          userId String User ID
          resourceId String Resource ID
          metricName String Metric name
          dimensions List<Dimensions> Dimension list
          dataPoints List<DataPoint> Monitor Metric data

          DataPoint

          Name Types Description
          average double Average of Metrics within the statistical period
          sum double Sum of Metrics within the statistical period
          minimum double Minimum value of Metrics within the statistical period
          maximum double Maximum value of Metrics within the counting cycle
          sampleCount int Number of DataPoints for the Metric within the statistical period
          value int Original value of Metrics within the counting cycle
          timestamp DateTime Time corresponding to the statistical period of Metric, refer to [Date and Time](BCM/API Reference/General Description.md), expressed in UTC date

          Request example

          // config of client
          String endpoint = "http://bcm.bj.baidubce.com";
          String userId = "a0d04d7c***************7b6752ce4";
          String ak = "ALTAK***************3hVCYG";
          String sk = "b2c53*******************f9993ac1";
          // create a bcm client
          BcmClientConfiguration config = new BcmClientConfiguration();
          config.setCredentials(new DefaultBceCredentials(ak, sk));
          config.setEndpoint(endpoint);
          BcmClient bcmClient = new BcmClient(config);
          // request params definition
          MultiDimensionalLatestMetricsRequest request = new MultiDimensionalLatestMetricsRequest();
          ArrayList<String> metrics = new ArrayList<String>();
          metrics.add("ActiveConnCount");
          ArrayList<Dimension> dimensions = new ArrayList<Dimension>();
          dimensions.add(new Dimension("BlbId", "lb-0f8e****"));
          request.setUserId(userId);
          request.setScope("BCE_BLB");
          request.setMetricNames(metrics);
          request.setDimensions(dimensions);
          MultiDimensionalLatestMetricsResponse res = bcmClient.getMultiDimensionalLatestMetrics(request);

          Response result

          {
            "metadata" : {
              "bceRequestId" : "71b8b65a-7b09-4811-a71a-bf6d937c762c",
              "transferEncoding" : "chunked",
              "contentLength" : -1,
              "contentType" : "application/json;charset=UTF-8",
              "date" : 1713151664000
            },
            "requestId" : "71b8b65a-7b09-4811-a71a-bf6d937c762c",
            "code" : "success",
            "metrics" : [ {
              "region" : "bj",
              "scope" : "BCE_BLB",
              "userId" : "a0d04d7c***************7b6752ce4",
              "resourceId" : "lb-0f8e****",
              "metricName" : "ActiveConnCount",
              "dimensions" : [ {
                "name" : "BlbId",
                "value" : "lb-0f8e****"
              }, {
                "name" : "BlbPort",
                "value" : "27017"
              }, {
                "name" : "BlbPortType",
                "value" : "TCP"
              } ],
              "dataPoints" : [ {
                "value" : 0.0,
                "timestamp" : "2024-04-15T03:27:44Z"
              } ]
            }, {
              "region" : "bj",
              "scope" : "BCE_BLB",
              "userId" : "a0d04d7c***************7b6752ce4",
              "resourceId" : "lb-0f8e****",
              "metricName" : "ActiveConnCount",
              "dimensions" : [ {
                "name" : "BlbId",
                "value" : "lb-0f8e****"
              } ],
              "dataPoints" : [ {
                "value" : 0.0,
                "timestamp" : "2024-04-15T03:27:44Z"
              } ]
            } ]
          }
          Previous
          Query Data API
          Next
          Query Monitoring Data for Partial Dimensions