Query Latest Metric Data for Partial Dimensions
Updated at:2025-11-03
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
Java
1// config of client
2String endpoint = "http://bcm.bj.baidubce.com";
3String userId = "a0d04d7c***************7b6752ce4";
4String ak = "ALTAK***************3hVCYG";
5String sk = "b2c53*******************f9993ac1";
6// create a bcm client
7BcmClientConfiguration config = new BcmClientConfiguration();
8config.setCredentials(new DefaultBceCredentials(ak, sk));
9config.setEndpoint(endpoint);
10BcmClient bcmClient = new BcmClient(config);
11// request params definition
12MultiDimensionalLatestMetricsRequest request = new MultiDimensionalLatestMetricsRequest();
13ArrayList<String> metrics = new ArrayList<String>();
14metrics.add("ActiveConnCount");
15ArrayList<Dimension> dimensions = new ArrayList<Dimension>();
16dimensions.add(new Dimension("BlbId", "lb-0f8e****"));
17request.setUserId(userId);
18request.setScope("BCE_BLB");
19request.setMetricNames(metrics);
20request.setDimensions(dimensions);
21MultiDimensionalLatestMetricsResponse res = bcmClient.getMultiDimensionalLatestMetrics(request);
Response result
Java
1{
2 "metadata" : {
3 "bceRequestId" : "71b8b65a-7b09-4811-a71a-bf6d937c762c",
4 "transferEncoding" : "chunked",
5 "contentLength" : -1,
6 "contentType" : "application/json;charset=UTF-8",
7 "date" : 1713151664000
8 },
9 "requestId" : "71b8b65a-7b09-4811-a71a-bf6d937c762c",
10 "code" : "success",
11 "metrics" : [ {
12 "region" : "bj",
13 "scope" : "BCE_BLB",
14 "userId" : "a0d04d7c***************7b6752ce4",
15 "resourceId" : "lb-0f8e****",
16 "metricName" : "ActiveConnCount",
17 "dimensions" : [ {
18 "name" : "BlbId",
19 "value" : "lb-0f8e****"
20 }, {
21 "name" : "BlbPort",
22 "value" : "27017"
23 }, {
24 "name" : "BlbPortType",
25 "value" : "TCP"
26 } ],
27 "dataPoints" : [ {
28 "value" : 0.0,
29 "timestamp" : "2024-04-15T03:27:44Z"
30 } ]
31 }, {
32 "region" : "bj",
33 "scope" : "BCE_BLB",
34 "userId" : "a0d04d7c***************7b6752ce4",
35 "resourceId" : "lb-0f8e****",
36 "metricName" : "ActiveConnCount",
37 "dimensions" : [ {
38 "name" : "BlbId",
39 "value" : "lb-0f8e****"
40 } ],
41 "dataPoints" : [ {
42 "value" : 0.0,
43 "timestamp" : "2024-04-15T03:27:44Z"
44 } ]
45 } ]
46}
