搜索本产品文档关键词
部分维度查询最新指标数据
所有文档
menu

云监控 BCM

部分维度查询最新指标数据

接口描述

可根据多维度、多指标、多统计数据获取云产品指定时刻指标监控数据、站点监控数据或您推送的自定义监控数据。

接口限制

  • 每次查询的维度组合数量不超过100个。
  • 每次查询的指标名称数量不超过30个。

请求结构

  • 请求方法:POST
  • 请求URL:/csm/api/v2/userId/{userId}/services/{scope}/data/metricData/latest/batch

请求参数

名称
类型
描述
是否必须
参数位置
userId String 用户ID Body参数
scope String 云产品标识,取值请参考云产品标识列表 Body参数
region String 区域标识,取值请参考区域列表 Body参数
resourceType String 监控对象类型,默认值:Instance,取值请参考云产品监控对象类型列表 Body参数
metricNames List<String> 监控指标列表 Body参数
statistics List<String> 统计方法类型列表,可选值:average、maximum、minimum、sum、sampleCount。为空时默认返回最新原始值 Body参数
dimensions List<Dimension> 维度列表 Body参数
cycle int 统计周期,单位:秒,默认为60,上限为3600 Body参数
timestamp DateTime 监控项统计周期对应的时间,默认为当前时间。请参考日期与时间,UTC日期表示 Body参数

Dimension

名称
类型
描述
是否必须
参数位置
name String 维度key Body参数
value String 维度value Body参数

参数解释

-云产品标识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<Dimensions> 维度列表
dataPoints List<DataPoint> 监控指标数据

DataPoint

名称
类型
描述
average double 统计周期内监控项的平均值
sum double 统计周期内监控项的和值
minimum double 统计周期内监控项的最小值
maximum double 统计周期内监控项的最大值
sampleCount int 统计周期内监控项数据点数
value int 统计周期内监控项的原始值
timestamp DateTime 监控项统计周期对应的时间,请参考日期与时间,UTC日期表示

请求示例

Python
1// config of client
2HOST = 'http://bcm.bj.baidubce.com/'
3AK = 'ALTA****************3hVCYG' 
4SK = 'b2c53***********************3ac1'
5config = BceClientConfiguration(credentials=BceCredentials(AK, SK), endpoint=HOST)
6
7# params definition
8user_id = "a0d04d7c***************7b6752ce4" 
9scope = "BCE_BLB"
10metric_name = ["ActiveConnCount", "DropOutBytes"]
11dimensions = [{"name": "BlbId", "value": "lb-0f8e****"}]
12statistics = ["average","sum","minimum"]
13timestamp="2024-04-15T03:01:00Z"
14
15# create a bcm client
16bcm_client = BcmClient(config)
17
18res = self.client.get_multi_dimension_latest_metrics(user_id,
19                                                     scope,
20                                                     metric_names,
21                                                     statistics,
22                                                     dimensions,
23                                                     timestamp)

返回结果

Python
1{
2    "metadata": {
3        "date": "Mon, 15 Apr 2024 03:50:02 GMT",
4        "x_trace_id": "19c116bd-e046-433a-af2a-47a705c66150",
5        "x_trace_timestamp": "1713153002988",
6        "x_trace_consumer_ip": "172.18.64.107",
7        "x_trace_provider_ip": "10.211.83.158",
8        "x_application_context": "application:8869",
9        "x_user_request_id": "e2287076-589e-492d-83d3-79585343f4f7",
10        "x_protected_by": "OpenRASP 2.0",
11        "bce_request_id": "fd53de57-334e-437d-b301-652152c987e1",
12        "x_b3_traceid": "fd53de57334e437db301652152c987e1",
13        "cache_control": "no-cache",
14        "responsehostnamesting": "szth-bcm-online-00006.szth.baidu.com",
15        "responsehostip": "10.174.228.36",
16        "x_content_type_options": "nosniff",
17        "x_xss_protection": "1; mode=block",
18        "x_frame_options": "DENY",
19        "content_type": "application/json;charset=UTF-8",
20        "transfer_encoding": "chunked"
21    },
22    "request_id": "fd53de57-334e-437d-b301-652152c987e1",
23    "code": "success",
24    "message": None,
25    "metrics": [
26        {
27            "region": "bj",
28            "scope": "BCE_BLB",
29            "user_id": "a0d04d7c***************7b6752ce4",
30            "resource_id": "lb-0f8e9bad",
31            "metric_name": "ActiveConnCount",
32            "dimensions": [
33                {"name": "BlbId", "value": "lb-0f8e9bad"},
34                {"name": "BlbPort", "value": "27017"},
35                {"name": "BlbPortType", "value": "TCP"}
36            ],
37            "data_points": [{"average": 0.0, "sum": 0.0, "minimum": 0.0, "timestamp": "2024-04-15T03:01:00Z"}]
38        },
39        {
40            "region": "bj",
41            "scope": "BCE_BLB",
42            "user_id": "a0d04d7c***************7b6752ce4",
43            "resource_id": "lb-0f8e9bad",
44            "metric_name": "DropOutBytes",
45            "dimensions": [
46                {"name": "BlbId", "value": "lb-0f8e9bad"},
47                {"name": "BlbPort", "value": "27017"},
48                {"name": "BlbPortType", "value": "TCP"}
49            ],
50            "data_points": [{"average": 0.0, "sum": 0.0, "minimum": 0.0, "timestamp": "2024-04-15T03:01:00Z"}]
51        },
52        {
53            "region": "bj",
54            "scope": "BCE_BLB",
55            "user_id": "a0d04d7c***************7b6752ce4",
56            "resource_id": "lb-0f8e9bad",
57            "metric_name": "ActiveConnCount",
58            "dimensions": [{"name": "BlbId", "value": "lb-0f8e9bad"}],
59            "data_points": [{"average": 0.0, "sum": 0.0, "minimum": 0.0, "timestamp": "2024-04-15T03:01:00Z"}]
60        }
61    ]
62}
上一篇
部分维度查询监控数据
下一篇
维度值TopN查询接口