部分维度查询监控数据
更新时间:2024-04-18
接口描述
可根据多维度、单指标、多统计数据获取云产品指定时间范围内的监控数据。
接口限制
- 一个实例的任意一个指标一次返回的数据点数目不能超过1440个。
- 每次查询的维度组合数量不超过100个。
请求结构
- Method: POST
- Url: /csm/api/v2/userId/{userId}/services/{service}/data/metricData/PartialDimension
请求参数
名称 | 类型 | 描述 | 是否必须 | 参数位置 |
---|---|---|---|---|
userId | String | 用户 ID | 是 | Path参数 |
service | String | 云产品标识,取值请参考云产品标识列表 | 是 | Path参数 |
startTime | String | 监控数据开始时间,请参考日期与时间, UTC日期表示 | 是 | Body参数 |
endTime | String | 监控数据结束时间,请参考日期与时间,UTC日期表示 | 是 | Body参数 |
statistics | List<String> | 统计方法类型列表,可选值:average、maximum、minimum、sum、sampleCount | 是 | Body参数 |
cycle | int | 统计周期,单位:秒,默认值:60 | 否 | Body参数 |
dimensions | List<Dimension> | 维度列表 | 是 | Body参数 |
resourceType | String | 监控对象类型,取值请参考云产品监控对象类型列表 | 否 | Body参数 |
metricName | String | 监控指标名称 | 是 | Body参数 |
region | String | 区域标识,取值请参考区域列表 | 否 | Body参数 |
pageNo | int | 页面序号,默认为1 | 否 | Body参数 |
pageSize | int | 页面大小,默认为10,最大为100 | 否 | Body参数 |
Dimension
名称 | 类型 | 描述 | 是否必须 |
---|---|---|---|
name | String | 维度key | 是 |
value | String | 维度value | 是 |
响应参数
名称 | 类型 | 描述 |
---|---|---|
requestId | String | 请求标识 |
code | String | 返回码 |
message | String | 错误信息 |
result | PageResult | 按页封装的结果 |
PageResult
名称 | 类型 | 描述 |
---|---|---|
pageNo | int | 页码编号 |
pageSize | int | 页面大小 |
totalCount | int | 总共个数 |
result | List<AllDataMetric> | 监控指标列表 |
AllDataMetric
名称 | 类型 | 描述 |
---|---|---|
region | String | 区域标识 |
scope | String | 云产品标识 |
userId | String | 用户ID |
resourceId | String | 资源ID |
metricName | String | 监控指标名称 |
dimensions | List<Dimensions> | 维度列表 |
dataPoints | List<DataPoint> | 监控指标数据 |
DataPoint
名称 | 类型 | 描述 |
---|---|---|
average | double | 统计周期内监控项的平均值 |
sum | double | 统计周期内监控项的和值 |
minimum | double | 统计周期内监控项的最小值 |
maximum | double | 统计周期内监控项的最大值 |
sampleCount | int | 统计周期内监控项数据点数 |
timestamp | String | 监控数据对应的时间 |
请求示例
Java
1// config of client
2String endpoint = "http://bcm.bj.baidubce.com";
3String userId = "a0d04d7c***************7b6752ce4";
4String ak = "ALTAK***************3hVCYG";
5String sk = "b2c53*******************f9993ac1";
6
7// create a bcm client
8BcmClientConfiguration config = new BcmClientConfiguration();
9config.setCredentials(new DefaultBceCredentials(ak, sk));
10config.setEndpoint(endpoint);
11BcmClient bcmClient = new BcmClient(config);
12
13// request params definition
14List<Dimension> dimensions = new ArrayList<Dimension>();
15Dimension dimension = new Dimension();
16dimension.setName("BlbPortType");
17dimension.setValue("TCP");
18dimensions.add(dimension);
19List<String> statistics = new ArrayList<String>();
20statistics.add("sum");
21
22PartialDimensionsMetricsRequest request = new PartialDimensionsMetricsRequest();
23request.setScope("BCE_BLB");
24request.setUserId(userId);
25request.setMetricName("ActiveConnCount");
26request.setDimensions(dimensions);
27request.setRegion("bj");
28request.setStatistics(statistics);
29request.setStartTime("2024-03-20T02:21:17Z");
30request.setEndTime("2024-03-20T03:21:17Z");
31request.setResourceType("Blb");
32request.setPageNo(1);
33request.setPageSize(1);
34TsdbMetricResult<PageResultResponse<TsdbMetricAllDataResult.AllDataMetric>> result = bcmClient.getMetricsByPartialDimensions(request);
35
响应示例
JSON
1{
2 "metadata": {
3 "bceRequestId": "bfdb5d91-39e6-4c35-aa73-caf76ad3440f",
4 "transferEncoding": "chunked",
5 "contentLength": -1,
6 "contentType": "application/json;charset=UTF-8",
7 "date": 1713138814000
8 },
9 "requestId": "bfdb5d91-39e6-4c35-aa73-caf76ad3440f",
10 "code": "success",
11 "message": "",
12 "result": {
13 "pageNo": 1,
14 "pageSize": 1,
15 "totalCount": 66,
16 "result": [{
17 "region": "bj",
18 "scope": "BCE_BLB",
19 "userId": "a0d04d7c***************7b6752ce4",
20 "resourceId": "lb-****8446",
21 "metricName": "ActiveConnCount",
22 "dimensions": [{
23 "name": "BlbId",
24 "value": "lb-****8446"
25 }, {
26 "name": "BlbPort",
27 "value": "3306"
28 }, {
29 "name": "BlbPortType",
30 "value": "TCP"
31 }],
32 "dataPoints": [{
33 "sum": 0.0,
34 "timestamp": "2024-03-20T02:21:17Z"
35 }, {
36 "sum": 0.0,
37 "timestamp": "2024-03-20T02:22:17Z"
38 },
39 // 省略中间点
40 {
41 "sum": 0.0,
42 "timestamp": "2024-03-20T03:19:17Z"
43 }, {
44 "sum": 0.0,
45 "timestamp": "2024-03-20T03:20:17Z"
46 }, {
47 "timestamp": "2024-03-20T03:21:17Z"
48 }]
49 }]
50 }
51}