Batch Data Query Interface
Last Updated:2025-11-14
API description
API for batch instance queries, supporting multi-dimensional and multi-metric retrieval of Cloud Product Monitor data, Site Monitor data, or your custom monitor data.
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 |
|---|---|---|---|---|
| user_id | String | Tenant ID | Yes | URL parameter |
| scope | String, limited to the following character set: 0~9, A~Z, a~z, _ | Scope | Yes | URL parameter |
| metric_name | String, only the following character collection can be used: "0~9, A~Z, a~z", "_" . To query multiple metrics, separate them with commas, as format of metric1,metric2,metric3. |
Monitor Metric name | Yes | URL parameter |
| 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 monitor metrics have multiple dimensions, connect them with commas, e.g., dimensionName:dimensionValue;dimensionName:dimensionValue. Only one dimension value can be specified for the same dimension . To query batch instance data, connect each instance's full dimensions with commas, e.g., dimensionName:dimensionValue,dimensionName:dimensionValue |
Dimension list | Yes | Query |
| start_time | DateTime, refer to Date and Time, expressed in UTC date | Query start time | Yes | Query |
| end_time | DateTime, refer to Date and Time, expressed in UTC date | Query end time | Yes | Query |
| period_in_second | 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
user_id = "453bf9********************9090dc"
scope = "BCE_BCC"
metric_name = "CPUUsagePercent,MemUsagePercent"
dimensions = "InstanceId:i-YB****4F,InstanceId:i-R6****xl"
statistics = "average,maximum"
start_time = "2022-05-16T08:25:55Z"
end_time = "2022-05-16T09:25:55Z"
period_in_second = 60
# create a bcm client
bcm_client = BcmClient(bcm_sample_conf.config)
# get batch metric data
try:
response = bcm_client.get_batch_metric_data(user_id=user_id,
scope=scope,
metric_name=metric_name,
dimensions=dimensions,
statistics=statistics,
start_time=start_time,
end_time=end_time,
period_in_second=period_in_second)
print response
except BceHttpClientError as e:
if isinstance(e.last_error, BceServerError):
__logger.error('send request failed. Response %s, code: %s, msg: %s'
% (e.last_error.status_code, e.last_error.code, e.last_error.message))
else:
__logger.error('send request failed. Unknown exception: %s' % e)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"
}
]
}
]
}