API description
Monitor data from cloud products within a specified time range can be fetched using multiple dimensions, a single metric, and various statistics.
API restriction
- For any metric of a specific instance, the number of data points returned in one response cannot exceed 1,440.
- Each query can include up to 100 dimension combinations.
Request structure
- Method: POST
- Url: /csm/api/v2/userId/{userId}/services/{service}/data/metricData/PartialDimension
Request parameters
| Name |
Types |
Description |
Required or not |
Parameter location |
| userId |
String |
User ID |
Yes |
Path |
| service |
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 |
Path |
| startTime |
String |
Monitor data start time, refer to [Date and Time](BCM/API Reference/General Description.md), expressed in UTC date |
Yes |
Body |
| endTime |
String |
Monitor data end time, refer to [Date and Time](BCM/API Reference/General Description.md), expressed in UTC date |
Yes |
Body |
| statistics |
List<String> |
List of Statistic Method Types, options: average, maximum, minimum, sum, sampleCount. |
Yes |
Body |
| cycle |
int |
Statistical period, unit: second, default value: 60 |
No |
Body |
| dimensions |
List<Dimension> |
Dimension list |
Yes |
Body |
| resourceType |
String |
Monitor object type. For values, refer to [Cloud Product Monitor Object Type List](BCM/Cloud Product Monitor List/Cloud Product Monitor Object Type List.md) |
No |
Body |
| metricName |
String |
Monitor Metric name |
Yes |
Body |
| region |
String |
Region identifier. For values, refer to [Region List](BCM/API Reference/Service domain.md) |
No |
Body |
| pageNo |
int |
Page number, defaulting to 1 |
No |
Body |
| pageSize |
int |
Page size, default: 10, maximum: 100 |
No |
Body |
Dimension
| Name |
Types |
Description |
Required or not |
| name |
String |
Dimension key |
Yes |
| value |
String |
Dimension value |
Yes |
Response parameters
| Name |
Types |
Description |
| requestId |
String |
Request identifier |
| code |
String |
Return code |
| message |
String |
Error message |
| result |
PageResult |
Paginated results |
| Name |
Types |
Description |
| pageNo |
int |
Page number |
| pageSize |
int |
Page size |
| totalCount |
int |
Total count |
| result |
List<AllDataMetric> |
List of Monitor Metrics |
AllDataMetric
| Name |
Types |
Description |
| region |
String |
Region identifier |
| scope |
String |
Cloud product identifier |
| userId |
String |
User ID |
| resourceId |
String |
Resource ID |
| metricName |
String |
Monitor 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 |
| timestamp |
String |
Time corresponding to the monitor data |
Request example
String endpoint = "http://bcm.bj.baidubce.com";
String userId = "a0d04d7c***************7b6752ce4";
String ak = "ALTAK***************3hVCYG";
String sk = "b2c53*******************f9993ac1";
BcmClientConfiguration config = new BcmClientConfiguration();
config.setCredentials(new DefaultBceCredentials(ak, sk));
config.setEndpoint(endpoint);
BcmClient bcmClient = new BcmClient(config);
List<Dimension> dimensions = new ArrayList<Dimension>();
Dimension dimension = new Dimension();
dimension.setName("BlbPortType");
dimension.setValue("TCP");
dimensions.add(dimension);
List<String> statistics = new ArrayList<String>();
statistics.add("sum");
PartialDimensionsMetricsRequest request = new PartialDimensionsMetricsRequest();
request.setScope("BCE_BLB");
request.setUserId(userId);
request.setMetricName("ActiveConnCount");
request.setDimensions(dimensions);
request.setRegion("bj");
request.setStatistics(statistics);
request.setStartTime("2024-03-20T02:21:17Z");
request.setEndTime("2024-03-20T03:21:17Z");
request.setResourceType("Blb");
request.setPageNo(1);
request.setPageSize(1);
TsdbMetricResult<PageResultResponse<TsdbMetricAllDataResult.AllDataMetric>> result = bcmClient.getMetricsByPartialDimensions(request);
Response example
{
"metadata": {
"bceRequestId": "bfdb5d91-39e6-4c35-aa73-caf76ad3440f",
"transferEncoding": "chunked",
"contentLength": -1,
"contentType": "application/json;charset=UTF-8",
"date": 1713138814000
},
"requestId": "bfdb5d91-39e6-4c35-aa73-caf76ad3440f",
"code": "success",
"message": "",
"result": {
"pageNo": 1,
"pageSize": 1,
"totalCount": 66,
"result": [{
"region": "bj",
"scope": "BCE_BLB",
"userId": "a0d04d7c***************7b6752ce4",
"resourceId": "lb-****8446",
"metricName": "ActiveConnCount",
"dimensions": [{
"name": "BlbId",
"value": "lb-****8446"
}, {
"name": "BlbPort",
"value": "3306"
}, {
"name": "BlbPortType",
"value": "TCP"
}],
"dataPoints": [{
"sum": 0.0,
"timestamp": "2024-03-20T02:21:17Z"
}, {
"sum": 0.0,
"timestamp": "2024-03-20T02:22:17Z"
},
{
"sum": 0.0,
"timestamp": "2024-03-20T03:19:17Z"
}, {
"sum": 0.0,
"timestamp": "2024-03-20T03:20:17Z"
}, {
"timestamp": "2024-03-20T03:21:17Z"
}]
}]
}
}