Batch Data Query Interface
Updated at:2025-11-03
API description
API for retrieving batch instance data, supporting multi-dimensional and multi-metric queries, including data from Cloud Product Monitor, Site Monitor, or custom monitor data you've pushed.
API restriction
• The maximum number of DataPoints returned for any metric of an instance in one response is 1,440.
Request parameters
| Name | Types | Description | Required or not | Parameter location |
|---|---|---|---|---|
| userId | String | Tenant ID | Yes | URL parameter |
| scope | String, limited to the following character set: 0~9, A~Z, a~z, _ | Scope | Yes | URL parameter |
| metricName | String, limited to the following character set: "0~9, A~Z, a~z", "_" . When searching for multiple Metrics, use a String array, with each array element being a Metric. |
Monitor Metric name | Yes | Query |
| statistics | Statistics, in statistics1, statistics2, statistics3 format, options: average, maximum, minimum, sum, sampleCount | Statistic Method Type | Yes | Query |
| dimensions | String, composed of dimensionName:dimensionValue. When a Metric has multiple Dimensions, connect them with semicolons, e.g., dimensionName:dimensionValue;dimensionName:dimensionValue. Only one dimension value can be specified for the same dimension. When querying batch instance data, connect complete dimensions of each instance with commas, e.g., dimensionName:dimensionValue,dimensionName:dimensionValue |
Dimension list | Yes | Query |
| startTime | DateTime, refer to Date and Time, expressed in UTC date | Query start time | Yes | Query |
| endTime | DateTime, refer to Date and Time, expressed in UTC date | Query end time | Yes | Query |
| periodInSecond | int, multiple of 60, unit: second (s) | Statistical Period | Yes | Query |
Parameter explanation
- For concepts 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 |
| errorList | List<ErrorMetricData> | Invalid Monitor Metrics |
| successList | List<SuccessMetricData> | Successful Monitor Metrics |
ErrorMetricData
| Name | Types | Description |
|---|---|---|
| metricName | String | Metric name |
| message | String | Error message |
| dimensions | List<Dimension> | Dimension Information |
SuccessMetricData
| Name | Types | Description |
|---|---|---|
| metricName | String | Metric name |
| dimensions | List<Dimension> | Dimension Information |
| dataPoints | List<DataPoint> | Monitor Metric |
Dimension
| Name | Types | Description |
|---|---|---|
| name | String | Dimension name |
| value | String | Dimension value |
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 |
| timestamp | DateTime, refer to [Date and Time](BCM/API Reference/General Description.md#Date and time regulations), expressed in UTC date | Time corresponding to the statistical period of Metric |
Request example
Go
1// Multiple instance IDs, separated by commas; e.g.: i-RN****Hw,i-YB****4F
2dimensions := map[string]string{
3 "InstanceId": "i-RN****Hw",
4}
5req := &model.BatchGetMetricDataRequest{
6 UserId: "453bf9********************9090dc",
7 Scope: "BCE_BCC",
8 MetricNames: []string{"vCPUUsagePercent", "CpuIdlePercent"},
9 Dimensions: dimensions,
10 Statistics: []string{"average", "sum"},
11 PeriodInSecond: 60,
12 StartTime: time.Now().UTC().Add(-2 * time.Hour).Format("2006-01-02T15:04:05Z"),
13 EndTime: time.Now().UTC().Add(-1 * time.Hour).Format("2006-01-02T15:04:05Z"),
14}
15resp, err := bcmClient.BatchGetMetricData(req)
Response result
Plain Text
1{
2 "metadata": {
3 "bceRequestId": "024348c6-1ef4-4ee5-a411-c48ddf6b9cdd"
4 },
5 "requestId": "024348c6-1ef4-4ee5-a411-c48ddf6b9cdd",
6 "code": "OK",
7 "message": "",
8 "errorList": null,
9 "successList": [
10 {
11 "metricName": "vCPUUsagePercent",
12 "dimensions": [
13 {
14 "name": "InstanceId",
15 "value": "i-RN****Hw"
16 }
17 ],
18 "dataPoints": [
19 {
20 "average": 5.974418891389501,
21 "sum": null,
22 "maximum": 5.974689065937,
23 "minimum": null,
24 "sampleCount": null,
25 "value": null,
26 "timestamp": "2024-04-11T07:01:00Z"
27 }
28 ]
29 },
30 {
31 "metricName": "CpuIdlePercent",
32 "dimensions": [
33 {
34 "name": "InstanceId",
35 "value": "i-RN****Hw"
36 }
37 ],
38 "dataPoints": [
39 {
40 "average": 0.4166418167165,
41 "sum": null,
42 "maximum": 0.483133433283,
43 "minimum": null,
44 "sampleCount": null,
45 "value": null,
46 "timestamp": "2024-04-11T07:01:00Z"
47 }
48 ]
49 }
50 ]
51}
