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
JSON
1POST /csm/api/v2/userId/user1/services/BCE_BLB/data/metricData/latest/batch HTTP/1.1
2Host:bcm.bj.baidubce.com:80
3{
4 "userId" : "453bf9588c*****f9ba2c984129090dc",
5 "region" : "bj",
6 "scope" : "BCE_BLB",
7 "resourceType" : "Instance",
8 "dimensions" : [
9 {
10 "name": "BlbId",
11 "value": "lb-8ce1****"
12 },
13 {
14 "name": "BlbPort",
15 "value": "8200"
16 }
17 ],
18 "metricNames": [
19 "ActiveConnCount"
20 ],
21 "timestamp" : "2024-03-18T06:01:00Z"
22 "statistics":[
23 "average",
24 "sum",
25 "minimum"
26 ],
27 "cycle" : 60
28}
Response example
JSON
1HTTP/1.1 200 OK
2x-bce-request-id: 8a53f39b25ff44c6b2f9ac5b75377bbb
3Content-Type: application/json;charset=UTF-8
4{
5 "requestId": "8a53f39b25ff44c6b2f9ac5b75377bbb",
6 "code": "success",
7 "message": null,
8 "metrics": [
9 {
10 "region": "bj",
11 "scope": "BCE_BLB",
12 "userId": "453bf9588c9*******a2c984129090dc",
13 "resourceId": "lb-8ce1e1a0",
14 "metricName": "ActiveConnCount",
15 "dimensions": [
16 {
17 "name": "BlbId",
18 "value": "lb-8ce1****"
19 },
20 {
21 "name": "BlbPort",
22 "value": "8200"
23 },
24 {
25 "name": "BlbPortType",
26 "value": "TCP"
27 }
28 ],
29 "dataPoints": [
30 {
31 "average": 3.0,
32 "sum": 3.0,
33 "minimum": 3.0,
34 "timestamp": "2024-03-18T06:01:00Z"
35 }
36 ]
37 }
38 ]
39}
