Batch Query Data Interface
Last Updated:2025-11-14
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](BCM/API Reference/General Description.md#Date and time regulations), expressed in UTC date | Query start time | Yes | Query |
| endTime | DateTime, refer to [Date and Time](BCM/API Reference/General Description.md#Date and time regulations), 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 | String | Time corresponding to the statistical period of Monitor item, expressed in UTC date |
Request example
// params definition
String endpoint = "bcm.bj.baidubce.com";
String userId = "453bf9********************9090dc";
String ak = "ALTA********************YG";
String sk = "b2c5************************3ac1";
String scope ="BCE_BCC";
String dimensions = "InstanceId:i-YB****4F,InstanceId:i-R6****xl";
String[] metrics = {"CPUUsagePercent", "MemUsedPercent"};
Statistics[] statistics = {Statistics.average, Statistics.maximum};
long now = System.currentTimeMillis();
String startTime = DateUtils.formatAlternateIso8601Date(new Date(now - 60 * 60 * 1000));
String endTime = DateUtils.formatAlternateIso8601Date(new Date(now));
int periodInSecond = 60;
// create a bcm client
BcmClientConfiguration config = new BcmClientConfiguration();
config.setCredentials(new DefaultBceCredentials(ak, sk));
config.setEndpoint(endpoint);
BcmClient client = new BcmClient(config);
// query metric data from bcm interface
ListMetricDataRequest request = new ListMetricDataRequest();
request.withUserId(userId)
.withScope(scope)
.withDimensions(dimensions)
.withMetricNames(metrics)
.withPeriodInSecond(periodInSecond)
.withStartTime(startTime)
.withEndTime(endTime)
.withStatistics(statistics);
ListMetricDataResponse response = client.getMetricData(request);
System.out.println(JsonUtils.toJsonString(response));Response result
{
"metadata": {
"bceRequestId": "024348c6-1ef4-4ee5-a411-c48ddf6b9cdd"
},
"requestId": "024348c6-1ef4-4ee5-a411-c48ddf6b9cdd",
"code": "OK",
"message": "",
"errorList": null,
"successList": [
{
"metricName": "MemUsedPercent",
"dimensions": [
{
"name": "InstanceId",
"value": "i-YB****4F"
}
],
"dataPoints": [
{
"average": 5.974418891389501,
"sum": null,
"maximum": 5.974689065937,
"minimum": null,
"sampleCount": null,
"value": null,
"timestamp": "2024-04-11T07:01:00Z"
}
]
},
{
"metricName": "CPUUsagePercent",
"dimensions": [
{
"name": "InstanceId",
"value": "i-R6****xl"
}
],
"dataPoints": [
{
"average": 0.4166418167165,
"sum": null,
"maximum": 0.483133433283,
"minimum": null,
"sampleCount": null,
"value": null,
"timestamp": "2024-04-11T07:01:00Z"
}
]
},
{
"metricName": "MemUsedPercent",
"dimensions": [
{
"name": "InstanceId",
"value": "i-R6****xl"
}
],
"dataPoints": [
{
"average": 4.961740077942499,
"sum": null,
"maximum": 4.97271004918,
"minimum": null,
"sampleCount": null,
"value": null,
"timestamp": "2024-04-11T07:01:00Z"
}
]
},
{
"metricName": "CPUUsagePercent",
"dimensions": [
{
"name": "InstanceId",
"value": "i-YB****4F"
}
],
"dataPoints": [
{
"average": 0.466666770871,
"sum": null,
"maximum": 0.599941845894,
"minimum": null,
"sampleCount": null,
"value": null,
"timestamp": "2024-04-11T07:01:00Z"
}
]
}
]
}