接口描述
可获取多实例、多指标、多统计数据的接口,可获取云产品监控数据、站点监控数据或您推送的自定义监控数据。
接口限制
- 一个实例的任意一个指标一次返回的数据点数目不能超过1440个。
- 一次请求最多支持查询100个实例。
请求参数
名称 |
类型 |
描述 |
是否必须 |
参数位置 |
userId |
String |
用户ID |
是 |
Body参数 |
scope |
String |
云产品标识,请参考云产品标识列表 |
是 |
Body参数 |
region |
String |
区域标识,取值请参考区域列表 |
是 |
Body参数 |
type |
String |
监控对象类型,请参考监控对象类型列表 |
是 |
Body参数 |
metricNames |
List<String> |
监控指标列表,仅限于使用如下字符集合:"0~9、A~Z、a~z"、 "_" 当需要查找多个指标项时,使用String数组存储,每个数组元素为一个指标项 |
是 |
Body参数 |
statistics |
List<String> |
统计方法类型列表,可选值为average、maximum、minimum、sum、sampleCount,需要查询多个统计值时,使用String数组存储 |
是 |
Body参数 |
dimensions |
List<List<Dimension>> |
维度列表,当需要查询多个实例的数据时,使用二维数组查询。一层数组设置多个实例,二层数组设置多个维度 |
是 |
Body参数 |
startTime |
String |
查询起始时间,请参考日期与时间,UTC日期表示 |
是 |
Body参数 |
endTime |
String |
查询截止时间,请参考日期与时间,UTC日期表示 |
是 |
Body参数 |
cycle |
int |
统计周期,60的倍数,单位:秒 |
是 |
Body参数 |
Dimension
名称 |
类型 |
描述 |
name |
String |
维度key |
value |
String |
维度value |
参数解释
- 名字空间scope、监控项metric、统计方法Statistic、维度Dimension等的概念请参考核心概念。
响应结果
名称 |
类型 |
描述 |
requestId |
String |
请求标识 |
code |
String |
返回码 |
message |
String |
错误信息 |
metrics |
List<AllDataMetric> |
监控指标 |
AllDataMetric
名称 |
类型 |
描述 |
region |
String |
区域 |
scope |
String |
云产品标识 |
userId |
String |
用户Id |
resourceId |
String |
资源Id |
metricName |
String |
指标名称 |
dimensions |
List<Dimension> |
维度列表 |
dataPoints |
List<DataPoints> |
指标数据 |
DataPoints
名称 |
类型 |
描述 |
average |
double |
统计周期内监控项的平均值 |
sum |
double |
统计周期内监控项的和值 |
minimum |
double |
统计周期内监控项的最小值 |
maximum |
double |
统计周期内监控项的最大值 |
sampleCount |
int |
统计周期内监控项数据点数 |
timestamp |
String |
监控项统计周期对应的时间,请参考日期与时间,UTC日期表示 |
请求示例
MultiDimensionalMetricsRequest request = new MultiDimensionalMetricsRequest();
request.setUserId("453bf9********************9090dc");
request.setScope("BCE_BCC");
List<String> metricNames = new ArrayList<String>();
metricNames.add("CPUUsagePercent");
metricNames.add("MemUsedPercent");
request.setMetricNames(metricNames);
request.setStartTime("2024-03-26T07:01:00Z");
request.setEndTime("2024-03-26T07:05:00Z");
List<List<Dimension>> dimensions = new ArrayList<List<Dimension>>();
List<Dimension> d1 = new ArrayList<Dimension>();
d1.add(new Dimension("InstanceId", "i-M9****s1"));
List<Dimension> d2 = new ArrayList<Dimension>();
d2.add(new Dimension("InstanceId", "i-8y****gG"));
dimensions.add(d1);
dimensions.add(d2);
request.setDimensions(dimensions);
List<String> statistics = new ArrayList<String>();
statistics.add("sum");
statistics.add("average");
request.setStatistics(statistics);
request.setRegion("bj");
TsdbMetricAllDataResult result = bcmClient.getAllDataMetricV2(request);
返回结果
{
"metadata": {
"bceRequestId": "9cc92f21-d697-4133-bf2d-bf5f944ce752",
"transferEncoding": "chunked",
"contentLength": -1,
"contentType": "application/json;charset=UTF-8",
"date": 1711508479000
},
"requestId": "9cc92f21-d697-4133-bf2d-bf5f944ce752",
"code": "success",
"message": "",
"metrics": [
{
"region": "bj",
"scope": "BCE_BCC",
"userId": "453bf9********************9090dc",
"resourceId": "i-8y****gG",
"metricName": "CPUUsagePercent",
"dimensions": [
{
"name": "InstanceId",
"value": "i-8y****gG"
}
],
"dataPoints": [
{
"timestamp": "2024-03-26T07:01:00Z",
"average": 7.9346566231995,
"sum": 15.869313246399
}
]
},
{
"region": "bj",
"scope": "BCE_BCC",
"userId": "453bf9********************9090dc",
"resourceId": "i-M9****s1",
"metricName": "MemUsedPercent",
"dimensions": [
{
"name": "InstanceId",
"value": "i-M9****s1"
}
],
"dataPoints": [
{
"timestamp": "2024-03-26T07:01:00Z",
"average": 27.4557088036185,
"sum": 54.911417607237
}
]
},
{
"region": "bj",
"scope": "BCE_BCC",
"userId": "453bf9********************9090dc",
"resourceId": "i-M9****s1",
"metricName": "CPUUsagePercent",
"dimensions": [
{
"name": "InstanceId",
"value": "i-M9****s1"
}
],
"dataPoints": [
{
"timestamp": "2024-03-26T07:01:00Z",
"average": 3.400926389583,
"sum": 6.801852779166
}
]
},
{
"region": "bj",
"scope": "BCE_BCC",
"userId": "453bf9********************9090dc",
"resourceId": "i-8y****gG",
"metricName": "MemUsedPercent",
"dimensions": [
{
"name": "InstanceId",
"value": "i-8y****gG"
}
],
"dataPoints": [
{
"timestamp": "2024-03-26T07:01:00Z",
"average": 20.5017433695395,
"sum": 41.003486739079
}
]
}
]
}