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
Go
1// config of client
2ak := "ALTAKr*****************CYG"
3sk := "b2c53**********************93ac1"
4userId := "a0d04***********************2ce4"
5endpoint := "http://bcm.bj.baidubce.com"
6bcmClient, _ = NewClient(ak, sk, endpoint)
7
8req := &model.MultiDimensionalLatestMetricsRequest{
9 UserID: bcmConf.UserId,
10 Scope: "BCE_BLB",
11 Region: "bj",
12 Dimensions: []model.Dimension{
13 {
14 Name: "BlbId",
15 Value: "lb-0f8e****",
16 },
17 },
18 Statistics: []string{"average", "sum"},
19 Timestamp: "2024-04-15T03:01:00Z",
20 MetricNames: []string{"ActiveConnCount"},
21 }
22response, err := bcmClient.GetMultiDimensionLatestMetrics(req)
Response result
Go
1{
2 "requestId": "37f328d8-0dbf-48a5-a355-97a68febb40d",
3 "code": "success",
4 "metrics": [
5 {
6 "region": "bj",
7 "scope": "BCE_BLB",
8 "userId": "a0d04***********************2ce4",
9 "resourceId": "lb-0f8e****",
10 "metricName": "ActiveConnCount",
11 "dimensions": [
12 {
13 "name": "BlbId",
14 "value": "lb-0f8e****"
15 },
16 {
17 "name": "BlbPort",
18 "value": "27017"
19 },
20 {
21 "name": "BlbPortType",
22 "value": "TCP"
23 }
24 ],
25 "dataPoints": [
26 {
27 "timestamp": "2024-04-15T03:01:00Z"
28 }
29 ]
30 },
31 {
32 "region": "bj",
33 "scope": "BCE_BLB",
34 "userId": "a0d04d7c202140cb80155ff7b6752ce4",
35 "resourceId": "lb-0f8e****",
36 "metricName": "ActiveConnCount",
37 "dimensions": [
38 {
39 "name": "BlbId",
40 "value": "lb-0f8e****"
41 }
42 ],
43 "dataPoints": [
44 {
45 "timestamp": "2024-04-15T03:01:00Z"
46 }
47 ]
48 }
49 ]
50}
