批量查询监控数据接口V2
更新时间:2024-04-16
接口描述
可获取多实例、多指标、多统计数据的接口,可获取云产品监控数据、站点监控数据或您推送的自定义监控数据。
接口限制
- 一个实例的任意一个指标一次返回的数据点数目不能超过1440个。
- 一次请求最多支持查询100个实例。
请求参数
名称 | 类型 | 描述 | 是否必须 | 参数位置 |
---|---|---|---|---|
user_id | String | 用户ID | 是 | Body参数 |
scope | String | 云产品标识,请参考云产品标识列表 | 是 | Body参数 |
region | string | 区域标识,取值请参考区域列表 | 是 | Body参数 |
type | string | 监控对象类型,请参考监控对象类型列表 | 是 | Body参数 |
metric_names | String[] | 监控指标列表,仅限于使用如下字符集合:"0~9、A~Z、a~z"、 "_" 当需要查找多个指标项时,使用String数组存储,每个数组元素为一个指标项 |
是 | Body参数 |
statistics | String[] | 统计方法类型列表,可选值为average、maximum、minimum、sum、sampleCount,需要查询多个统计值时,使用String数组存储 | 是 | Body参数 |
dimensions | Dimension[][] | 维度列表,当需要查询多个实例的数据时,使用二维数组查询。一层数组设置多个实例,二层数组设置多个维度 | 是 | Body参数 |
start_time | String | 查询起始时间,请参考日期与时间,UTC日期表示 | 是 | Body参数 |
end_time | String | 查询截止时间,请参考日期与时间,UTC日期表示 | 是 | Body参数 |
cycle | int | 统计周期,60的倍数,单位:秒 | 是 | Body参数 |
Dimension
名称 | 类型 | 描述 |
---|---|---|
name | string | 维度key |
value | string | 维度value |
参数解释
- 名字空间scope、监控项metric、统计方法Statistic、维度Dimension等的概念请参考核心概念。
响应结果
名称 | 类型 | 描述 |
---|---|---|
request_id | String | 请求标识 |
code | String | 返回码 |
message | String | 错误信息 |
metrics | AllDataMetric[] | 监控指标 |
AllDataMetric
名称 | 类型 | 描述 |
---|---|---|
region | String | 区域 |
scope | String | 云产品标识 |
user_id | String | 用户Id |
resource_id | String | 资源Id |
metric_name | String | 指标名称 |
dimensions | Dimension[] | 维度列表 |
data_points | DataPoints[] | 指标数据 |
DataPoints
名称 | 类型 | 描述 |
---|---|---|
average | float | 统计周期内监控项的平均值 |
sum | float | 统计周期内监控项的和值 |
minimum | float | 统计周期内监控项的最小值 |
maximum | float | 统计周期内监控项的最大值 |
sample_count | int | 统计周期内监控项数据点数 |
timestamp | String | 监控项统计周期对应的时间,请参考日期与时间,UTC日期表示 |
请求示例
Python
1 # params definition
2 user_id = "453bf9********************9090dc"
3 scope = "BCE_BCC"
4 region = "bj"
5 metric_names = ["CPUUsagePercent", "MemUsedPercent"]
6 dimensions = [
7 [
8 {
9 "name": "InstanceId",
10 "value": "i-YBW5U04F"
11 }
12 ],
13 [
14 {
15 "name": "InstanceId",
16 "value": "i-R6RloKxl"
17 }
18 ]
19 ]
20 statistics = ["average", "maximum", "minimum"]
21 start_time = "2024-04-11T07:01:00Z"
22 end_time = "2024-04-11T07:05:00Z"
23 cycle = 60
24 type = "Instance"
25
26 # create a bcm client
27 bcm_client = BcmClient(bcm_sample_conf.config)
28
29 # get batch metric data
30 response = bcm_client.get_all_data_metrics_v2(user_id, scope, region, dimensions, metric_names, statistics,
31 start_time, end_time, type=type, cycle=cycle)