统计接口(新版)
接口
本接口用于查询用户或域名的统计指标信息。
Method | Path | 说明 |
---|---|---|
POST | /v2/stat/query | 所有统计数据的路径,不同的统计指标由post参数中的metric指定。 |
默认接口请求频率限制:30次/秒。
默认请求体(Request Body)
所有metric支持的参数以此进行扩展。
参数 | 可选 | 类型 | 说明 |
---|---|---|---|
metric | 必选 | String | 示例:src_flow、flow、pv、pv_region、avg_speed等等。更多metric参数值请查看本页面中对应接口metric值。 |
endTime | 可选 | Timestamp | 查询的时间范围结束值,默认为当前时间,UTC时间 |
startTime | 可选 | Timestamp | 查询的时间范围起始值,默认为endTime前推24小时,UTC时间。60s查询粒度只能查询最近7天数据,300s粒度可查询最近90天数据,其他粒度可查询最近180天数据 |
period | 可选 | Long | 查询结果的粒度,单位秒,可选值为60、300、3600、86400,默认为300。uv 默认3600,topN查询最小3600。(选60s的时间粒度时建议startTime和endTime区间跨度建议选择0.5到1h,300s建议查询时间跨度在1天内,否则可能会因为数据量太大无法正常返回或返回数据粒度不正确) |
key_type | 可选 | Long | 标识key的内容,0=>域名,1=>用户id,2=>tag,默认0 |
key | 可选 | list<String> | 域名或用户Id或Tag,当查询key_type为tag时,key的格式为标签键或标签键:标签值。例如:标签键=默认项目,标签值=test,查询key参数key=["默认项目:test"]。当没有标签值时,key=["默认项目"] |
groupBy | 可选 | String | 返回结果聚合粒度,key => 根据key聚合, 空 => 返回整体结果 |
默认响应体(Response Body)
所有metric的响应结果以此扩展。
参数 | 类型 | 说明 |
---|---|---|
status | String | 正常返回的时候为"ok" |
details | list<Details> | list类型 |
count | Long | list的长度 |
Details 内容
参数 | 类型 | 说明 |
---|---|---|
timestamp | Timestamp | 时间点 UTC时间 |
key | String | 聚合粒度(groupBy):key => key,其他 => total |
... | Object | 扩展字段,metric对应的统计指标 |
平均速率相关接口
查询平均速率
metric:avg_speed
响应体扩展字段:
参数 | 类型 | 说明 |
---|---|---|
avgspeed | Long | 统计时间段内的平均速率 |
请求示例
1POST /v2/stat/query HTTP/1.1
2Host: cdn.baidubce.com
3
4{
5 "metric":"avg_speed",
6 "startTime":"2019-03-20T06:00:00Z",
7 "endTime":"2019-03-20T06:10:00Z",
8 "period":300,
9 "key_type":0,
10 "key":["cdaa.wonter.net"],
11 "groupBy":"key"
12}
返回示例
1HTTP/1.1 200 OK
2Content-Length: 190
3Content-Type: application/json;utf-8
4x-bce-request-id: 81d0b05f-5ad4-1f22-8068-d5c9de60a1d7
5Server: BCE-CDN
6
7{
8 "status": "ok",
9 "details": [
10 {
11 "timestamp": "2019-03-20T06:00:00Z",
12 "key": "cdaa.wonter.net",
13 "avgspeed": 1219463
14 },
15 {
16 "timestamp": "2019-03-20T06:05:00Z",
17 "key": "cdaa.wonter.net",
18 "avgspeed": 1289562
19 }
20 ],
21 "count": 2
22}
客户端访问分布查询平均速率
metric:avg_speed_region
请求体扩展字段:
参数 | 可选 | 类型 | 说明 |
---|---|---|---|
prov | 可选 | String | 查询的省份全拼,默认为空,查询全国数据。 |
isp | 可选 | String | 查询的运营商代码,默认为空,查询所有运营商数据。 |
响应体扩展字段:
参数 | 类型 | 说明 |
---|---|---|
distribution | list<DistributionData> | 客户端访问分布数据 |
DistributionData内容
参数 | 类型 | 说明 |
---|---|---|
location | String | 客户端所在省份、地区 |
isp | String | 客户端所属运营商 |
avgspeed | Long | 统计时间段内的平均速率 |
请求示例
1POST /v2/stat/query HTTP/1.1
2Host: cdn.baidubce.com
3
4{
5 "metric": "avg_speed_region",
6 "startTime": "2019-03-19T06:00:00Z",
7 "endTime": "2019-03-19T06:10:00Z",
8 "period": 300,
9 "key_type": 0,
10 "key": [
11 "cdaa.wonter.net"
12 ],
13 "groupBy": "key",
14 "prov": "beijing",
15 "isp": "ct"
16}
返回示例
1HTTP/1.1 200 OK
2Content-Length: 190
3Content-Type: application/json;utf-8
4x-bce-request-id: 81d0b05f-5ad4-1f22-8068-d5c9de60a1d7
5Server: BCE-CDN
6{
7 "status": "ok",
8 "details": [
9 {
10 "timestamp": "2019-03-19T06:00:00Z",
11 "key": "cdaa.wonter.net",
12 "distribution": [
13 {
14 "location": "北京",
15 "isp": "电信",
16 "avgspeed": 1683448
17 }
18 ]
19 },
20 {
21 "timestamp": "2019-03-19T06:05:00Z",
22 "key": "cdaa.wonter.net",
23 "distribution": [
24 {
25 "location": "北京",
26 "isp": "电信",
27 "avgspeed": 1964874
28 }
29 ]
30 }
31 ],
32 "count": 2
33}
pv/qps相关接口
pv/qps查询
metric:pv
请求体扩展字段:
参数 | 可选 | 类型 | 说明 |
---|---|---|---|
level | 可选 | String | 查询边缘或全局请求pv。可填写"all"或"edge",默认为“all” |
响应体扩展字段:
参数 | 类型 | 说明 |
---|---|---|
pv | Long | 统计时间段内的请求量 |
qps | Long | 统计时间段内的平均qps |
请求示例
1POST /v2/stat/query HTTP/1.1
2Host: cdn.baidubce.com
3
4{
5 "metric": "pv",
6 "startTime": "2019-03-20T06:00:00Z",
7 "endTime": "2019-03-20T06:10:00Z",
8 "period": 300,
9 "key_type": 0,
10 "key": [
11 "cdaa.wonter.net"
12 ],
13 "groupBy": "key",
14 "level": "edge"
15}
返回示例
1HTTP/1.1 200 OK
2Content-Length: 190
3Content-Type: application/json;utf-8
4x-bce-request-id: 81d0b05f-5ad4-1f22-8068-d5c9de60a1d7
5Server: BCE-CDN
6{
7 "status": "ok",
8 "details": [
9 {
10 "pv": 2145,
11 "qps": 7,
12 "timestamp": "2019-03-20T06:00:00Z",
13 "key": "cdaa.wonter.net"
14 },
15 {
16 "pv": 2950,
17 "qps": 9,
18 "timestamp": "2019-03-20T06:05:00Z",
19 "key": "cdaa.wonter.net"
20 }
21 ],
22 "count": 2
23}
pv/qps https协议查询
metric:pv_protocol
请求体扩展字段:
参数 | 可选 | 类型 | 说明 |
---|---|---|---|
protocol | 可选 | String | 查询指定协议的pv。可填写http、https、http3、all,默认all |
响应体扩展字段:
参数 | 类型 | 说明 |
---|---|---|
pv | Long | 统计时间段内的请求量 |
qps | Long | 统计时间段内的平均qps |
请求示例
1POST /v2/stat/query HTTP/1.1
2Host: cdn.baidubce.com
3
4{
5 "metric":"pv",
6 "startTime":"2019-03-20T06:00:00Z",
7 "endTime":"2019-03-20T06:10:00Z",
8 "period":300,
9 "key_type":0,
10 "key":["cdaa.wonter.net"],
11 "groupBy":"key",
12 "protocol":"https"
13}
返回示例
1HTTP/1.1 200 OK
2Content-Length: 190
3Content-Type: application/json;utf-8
4x-bce-request-id: 81d0b05f-5ad4-1f22-8068-d5c9de60a1d7
5Server: BCE-CDN
6{
7 "status": "ok",
8 "details": [
9 {
10 "pv": 2145,
11 "qps": 7,
12 "timestamp": "2019-03-20T06:00:00Z",
13 "key": "cdaa.wonter.net"
14 },
15 {
16 "pv": 2950,
17 "qps": 9,
18 "timestamp": "2019-03-20T06:05:00Z",
19 "key": "cdaa.wonter.net"
20 }
21 ],
22 "count": 2
23}
回源pv/qps查询
metric:pv_src
响应体扩展字段:
参数 | 类型 | 说明 |
---|---|---|
pv | Long | 统计时间段内的回源请求量 |
qps | Long | 统计时间段内的平均qps |
请求示例
1POST /v2/stat/query HTTP/1.1
2Host: cdn.baidubce.com
3
4{
5 "metric": "pv_src",
6 "startTime": "2019-03-20T06:00:00Z",
7 "endTime": "2019-03-20T06:10:00Z",
8 "period": 300,
9 "key_type": 0,
10 "key": [
11 "cdaa.wonter.net"
12 ],
13 "groupBy": "key"
14}
返回示例
1HTTP/1.1 200 OK
2Content-Length: 190
3Content-Type: application/json;utf-8
4x-bce-request-id: 81d0b05f-5ad4-1f22-8068-d5c9de60a1d7
5Server: BCE-CDN
6{
7 "status": "ok",
8 "details": [
9 {
10 "pv": 0,
11 "qps": 0,
12 "timestamp": "2019-03-20T06:00:00Z",
13 "key": "cdaa.wonter.net"
14 },
15 {
16 "pv": 0,
17 "qps": 0,
18 "timestamp": "2019-03-20T06:05:00Z",
19 "key": "cdaa.wonter.net"
20 }
21 ],
22 "count": 2
23}
查询pv/qps(分客户端访问分布)
metric: pv_region
请求体扩展字段:
参数 | 可选 | 类型 | 说明 |
---|---|---|---|
prov | 可选 | String | 查询的省份全拼,默认为空,查询全国数据 |
isp | 可选 | String | 查询的运营商代码,默认为空,查询所有运营商数据 |
protocol | 可选 | String | 查询的协议,可填写http3、all,默认all |
响应体扩展字段:
参数 | 类型 | 说明 |
---|---|---|
distribution | list<DistributionData> | 客户端访问分布数据 |
DistributionData内容
参数 | 类型 | 说明 |
---|---|---|
location | String | 客户端所在省份、地区 |
isp | String | 客户端所属运营商 |
pv | Long | 统计时间段内的请求量 |
qps | Long | 统计时间段内的平均qps |
请求示例
1POST /v2/stat/query HTTP/1.1
2Host: cdn.baidubce.com
3
4{
5 "metric": "pv_region",
6 "startTime": "2019-03-19T06:00:00Z",
7 "endTime": "2019-03-19T06:10:00Z",
8 "period": 300,
9 "key_type": 0,
10 "key": [
11 "cdaa.wonter.net"
12 ],
13 "groupBy": "key",
14 "prov": "beijing",
15 "isp": "ct"
16}
返回示例
1HTTP/1.1 200 OK
2Content-Length: 190
3Content-Type: application/json;utf-8
4x-bce-request-id: 81d0b05f-5ad4-1f22-8068-d5c9de60a1d7
5Server: BCE-CDN
6{
7 "status": "ok",
8 "details": [
9 {
10 "timestamp": "2019-03-19T06:00:00Z",
11 "key": "cdaa.wonter.net",
12 "distribution": [
13 {
14 "location": "北京",
15 "isp": "电信",
16 "pv": 148,
17 "qps": 0
18 }
19 ]
20 },
21 {
22 "timestamp": "2019-03-19T06:05:00Z",
23 "key": "cdaa.wonter.net",
24 "distribution": [
25 {
26 "location": "北京",
27 "isp": "电信",
28 "pv": 142,
29 "qps": 0
30 }
31 ]
32 }
33 ],
34 "count": 2
35}
uv查询
metric:uv
响应体扩展字段:
参数 | 类型 | 说明 |
---|---|---|
uv | Long | 统计时间段内的请求量 |
请求示例
1POST /v2/stat/query HTTP/1.1
2Host: cdn.baidubce.com
3
4{
5 "metric": "uv",
6 "startTime": "2019-03-20T06:00:00Z",
7 "endTime": "2019-03-20T06:10:00Z",
8 "period": 300,
9 "key_type": 0,
10 "key": [
11 "cdaa.wonter.net"
12 ],
13 "groupBy": "key"
14}
返回示例
1HTTP/1.1 200 OK
2Content-Length: 190
3Content-Type: application/json;utf-8
4x-bce-request-id: 81d0b05f-5ad4-1f22-8068-d5c9de60a1d7
5Server: BCE-CDN
6{
7 "status": "ok",
8 "details": [
9 {
10 "uv": 127994,
11 "timestamp": "2019-03-20T06:00:00Z",
12 "key": "cdaa.wonter.net"
13 },
14 {
15 "uv": 12700,
16 "timestamp": "2019-03-20T06:05:00Z",
17 "key": "cdaa.wonter.net"
18 }
19 ],
20 "count": 2
21}
流量带宽接口
查询流量、带宽
metric: flow
请求体扩展字段:
参数 | 可选 | 类型 | 说明 |
---|---|---|---|
level | 可选 | String | 查询边缘或全局请求流量、带宽。可填写"all"或"edge",默认为"all" |
响应体扩展字段:
参数 | 类型 | 说明 |
---|---|---|
flow | Long | 统计时间段内的传输字节数 |
bps | Long | 统计时间段内的平均bps |
请求示例
1POST /v2/stat/query HTTP/1.1
2Host: cdn.baidubce.com
3
4{
5 "metric": "flow",
6 "startTime": "2019-03-20T06:00:00Z",
7 "endTime": "2019-03-20T06:10:00Z",
8 "period": 300,
9 "key_type": 0,
10 "key": [
11 "cdaa.wonter.net"
12 ],
13 "groupBy": "key",
14 "level": "edge"
15}
返回示例
1HTTP/1.1 200 OK
2Content-Length: 190
3Content-Type: application/json;utf-8
4x-bce-request-id: 81d0b05f-5ad4-1f22-8068-d5c9de60a1d7
5Server: BCE-CDN
6{
7 "status": "ok",
8 "details": [
9 {
10 "flow": 88186275,
11 "bps": 2351634,
12 "timestamp": "2019-03-20T06:00:00Z",
13 "key": "cdaa.wonter.net"
14 },
15 {
16 "flow": 90383520,
17 "bps": 2410227,
18 "timestamp": "2019-03-20T06:05:00Z",
19 "key": "cdaa.wonter.net"
20 }
21 ],
22 "count": 2
23}
查询流量、带宽(静态)
metric: flow_static
请求体扩展字段:
参数 | 可选 | 类型 | 说明 |
---|---|---|---|
level | 可选 | String | 查询边缘或全局静态请求流量、带宽。可填写"all"或"edge",默认为"all" |
响应体扩展字段:
参数 | 类型 | 说明 |
---|---|---|
flow | Long | 统计时间段内的传输字节数 |
bps | Long | 统计时间段内的平均bps |
请求示例
1POST /v2/stat/query HTTP/1.1
2Host: cdn.baidubce.com
3
4{
5 "metric": "flow_static",
6 "startTime": "2019-03-20T06:00:00Z",
7 "endTime": "2019-03-20T06:10:00Z",
8 "period": 300,
9 "key_type": 0,
10 "key": [
11 "cdaa.wonter.net"
12 ],
13 "groupBy": "key",
14 "level": "edge"
15}
返回示例
1HTTP/1.1 200 OK
2Content-Length: 190
3Content-Type: application/json;utf-8
4x-bce-request-id: 81d0b05f-5ad4-1f22-8068-d5c9de60a1d7
5Server: BCE-CDN
6{
7 "status": "ok",
8 "details": [
9 {
10 "flow": 88186275,
11 "bps": 2351634,
12 "timestamp": "2019-03-20T06:00:00Z",
13 "key": "cdaa.wonter.net"
14 },
15 {
16 "flow": 90383520,
17 "bps": 2410227,
18 "timestamp": "2019-03-20T06:05:00Z",
19 "key": "cdaa.wonter.net"
20 }
21 ],
22 "count": 2
23}
查询流量、带宽(动态)
metric: flow_dynamic
请求体扩展字段:
参数 | 可选 | 类型 | 说明 |
---|---|---|---|
level | 可选 | String | 查询边缘或全局动态请求流量、带宽。可填写"all"或"edge",默认为"all" |
响应体扩展字段:
参数 | 类型 | 说明 |
---|---|---|
flow | Long | 统计时间段内的传输字节数 |
bps | Long | 统计时间段内的平均bps |
请求示例
1POST /v2/stat/query HTTP/1.1
2Host: cdn.baidubce.com
3
4{
5 "metric": "flow_dynamic",
6 "startTime": "2019-03-20T06:00:00Z",
7 "endTime": "2019-03-20T06:10:00Z",
8 "period": 300,
9 "key_type": 0,
10 "key": [
11 "cdaa.wonter.net"
12 ],
13 "groupBy": "key",
14 "level": "edge"
15}
返回示例
1HTTP/1.1 200 OK
2Content-Length: 190
3Content-Type: application/json;utf-8
4x-bce-request-id: 81d0b05f-5ad4-1f22-8068-d5c9de60a1d7
5Server: BCE-CDN
6{
7 "status": "ok",
8 "details": [
9 {
10 "flow": 88186275,
11 "bps": 2351634,
12 "timestamp": "2019-03-20T06:00:00Z",
13 "key": "cdaa.wonter.net"
14 },
15 {
16 "flow": 90383520,
17 "bps": 2410227,
18 "timestamp": "2019-03-20T06:05:00Z",
19 "key": "cdaa.wonter.net"
20 }
21 ],
22 "count": 2
23}
查询流量、带宽(分协议)
metric: flow_protocol
请求体扩展字段:
参数 | 可选 | 类型 | 说明 |
---|---|---|---|
protocol | 可选 | String | 查询各个协议的流量、带宽。可填写http、https、http3、all,默认all |
level | 可选 | String | 支持查询边缘的分协议流量。可填写all或edge,默认all |
注:protocol指定http3时,只有边缘流量,level参数无用
响应体扩展字段:
参数 | 类型 | 说明 |
---|---|---|
flow | Long | 统计时间段内的传输字节数 |
bps | Long | 统计时间段内的平均bps |
请求示例
1POST /v2/stat/query HTTP/1.1
2Host: cdn.baidubce.com
3
4{
5 "metric": "flow_protocol",
6 "startTime": "2019-03-20T06:00:00Z",
7 "endTime": "2019-03-20T06:10:00Z",
8 "period": 300,
9 "key_type": 0,
10 "key": [
11 "cdaa.wonter.net"
12 ],
13 "groupBy": "key",
14 "protocol": "all"
15}
返回示例
1HTTP/1.1 200 OK
2Content-Length: 190
3Content-Type: application/json;utf-8
4x-bce-request-id: 81d0b05f-5ad4-1f22-8068-d5c9de60a1d7
5Server: BCE-CDN
6{
7 "status": "ok",
8 "details": [
9 {
10 "flow": 88186275,
11 "bps": 2351634,
12 "timestamp": "2019-03-20T06:00:00Z",
13 "key": "cdaa.wonter.net"
14 },
15 {
16 "flow": 90383520,
17 "bps": 2410227,
18 "timestamp": "2019-03-20T06:05:00Z",
19 "key": "cdaa.wonter.net"
20 }
21 ],
22 "count": 2
23}
查询流量、带宽(分客户端访问分布)
metric: flow_region
请求体扩展字段:
参数 | 可选 | 类型 | 说明 |
---|---|---|---|
prov | 可选 | String | 查询的省份全拼,默认为空,查询全国数据 |
isp | 可选 | String | 查询的运营商代码,默认为空,查询所有运营商数据 |
protocol | 可选 | String | 查询的协议,可填写http3、all,默认all |
响应体扩展字段:
参数 | 类型 | 说明 |
---|---|---|
distribution | list<DistributionData> | 客户端访问分布数据 |
DistributionData内容
参数 | 类型 | 说明 |
---|---|---|
location | String | 客户端所在省份、地区 |
isp | String | 客户端所属运营商 |
flow | Long | 统计时间段内的传输字节数 |
bps | Long | 统计时间段内的平均bps |
请求示例
1POST /v2/stat/query HTTP/1.1
2Host: cdn.baidubce.com
3
4{
5 "metric": "flow_region",
6 "startTime": "2019-03-19T06:00:00Z",
7 "endTime": "2019-03-19T06:10:00Z",
8 "period": 300,
9 "key_type": 0,
10 "key": [
11 "cdaa.wonter.net"
12 ],
13 "groupBy": "key",
14 "prov": "beijing",
15 "isp": "ct"
16}
返回示例
1HTTP/1.1 200 OK
2Content-Length: 190
3Content-Type: application/json;utf-8
4x-bce-request-id: 81d0b05f-5ad4-1f22-8068-d5c9de60a1d7
5Server: BCE-CDN
6
7{
8 "status": "ok",
9 "details": [
10 {
11 "timestamp": "2019-03-19T06:00:00Z",
12 "key": "cdaa.wonter.net",
13 "distribution": [
14 {
15 "location": "北京",
16 "isp": "电信",
17 "flow": 918742,
18 "bps": 24499
19 }
20 ]
21 },
22 {
23 "timestamp": "2019-03-19T06:05:00Z",
24 "key": "cdaa.wonter.net",
25 "distribution": [
26 {
27 "location": "北京",
28 "isp": "电信",
29 "flow": 881491,
30 "bps": 23506
31 }
32 ]
33 }
34 ],
35 "count": 2
36}
查询月95峰值带宽
method | path | 说明 |
---|---|---|
POST | /v2/billing | 开放查询统计接口 |
请求参数
参数 | 可选 | 类型 | 说明 |
---|---|---|---|
domains | 可选 | string | 为','分隔的域名或标签 |
type | 必选 | string | 值为peak95,表查询月95带宽数据 |
withTag | 可选 | bool | 表示查询对象为tag还是domain,默认按 domain 查询,当参数值为 true时表按 tag 查询 |
byTime | 可选 | bool | 表示是否按整月查询,默认按整月查询,当参数值为true时按输入时间查询 |
billingMonth | 可选 | string | 整月查询时的开始查询月份,格式形如"year-month"。默认值为本月 |
startTime | 可选 | string | 开始时间,UTC格式。默认值为当前时间前24小时 |
endTime | 可选 | string | 结束时间,UTC格式。默认值为当前时间 |
注1:指定startTime和endTime时,byTime必须设置为true,否则指定时间不生效,按照整月查询。
注2:查询指定月份整月数据时,必须指定billingMonth,否则返回当前月份数据。
返回参数
参数 | 可选 | 类型 | 说明 |
---|---|---|---|
billing_details | 必选 | billing_detail | 查询的数据 |
billing_detail 类型说明
参数 | 可选 | 类型 | 说明 |
---|---|---|---|
bill_band | 必选 | int | 95带宽值 |
bill_time | 必选 | string | 该数据点的时间 |
请求示例
1HTTP/1.1 200 OK
2Server: nginx
3Date: Thu, 19 Dec 2019 04:26:40 GMT
4Content-Type: application/json; charset=utf-8
5Transfer-Encoding: chunked
6Connection: keep-alive
7X-Powered-By: PHP/7.1.5
8x-bce-request-id: aca2dd9e-77a6-7de8-b9d9-7561fb330ba5
9
10{
11 "type": "peak95",
12 "byTime": false, // byTime 为 false 时 startTime,endTime 参数无效
13 "startTime": "2019-12-17T16:00:00Z",
14 "endTime": "2019-12-18T06:53:33Z",
15 "billingMonth": "2018-11"
16}
返回示例
1{
2 "billing_details": {
3 "bill_band": 14536504775,
4 "bill_time": "2018-11-17T12:20:00Z"
5 }
6}
查询回源流量、回源带宽
metric:src_flow
响应体扩展字段:
参数 | 类型 | 说明 |
---|---|---|
flow | Long | 统计时间段内的传输字节数 |
bps | Long | 统计时间段内的平均bps |
请求示例
1POST /v2/stat/query HTTP/1.1
2Host: cdn.baidubce.com
3
4{
5 "metric": "src_flow",
6 "startTime": "2019-03-20T06:00:00Z",
7 "endTime": "2019-03-20T06:10:00Z",
8 "period": 300,
9 "key_type": 0,
10 "key": [
11 "cdaa.wonter.net"
12 ],
13 "groupBy": "key"
14}
返回示例
1HTTP/1.1 200 OK
2Content-Length: 190
3Content-Type: application/json;utf-8
4x-bce-request-id: 81d0b05f-5ad4-1f22-8068-d5c9de60a1d7
5Server: BCE-CDN
6{
7 "status": "ok",
8 "details": [
9 {
10 "flow": 0,
11 "bps": 0,
12 "timestamp": "2019-03-20T06:00:00Z"
13 },
14 {
15 "flow": 0,
16 "bps": 0,
17 "timestamp": "2019-03-20T06:05:00Z"
18 }
19 ],
20 "count": 2
21}
命中率类接口
字节命中率查询
metric:real_hit
响应体扩展字段:
参数 | 类型 | 说明 |
---|---|---|
hitrate | Double | 统计时间段内的字节命中率 |
请求示例
1POST /v2/stat/query HTTP/1.1
2Host: cdn.baidubce.com
3
4{
5 "metric": "real_hit",
6 "startTime": "2019-03-20T06:00:00Z",
7 "endTime": "2019-03-20T06:10:00Z",
8 "period": 300,
9 "key_type": 0,
10 "key": [
11 "cdaa.wonter.net"
12 ],
13 "groupBy": "key"
14}
返回示例
1HTTP/1.1 200 OK
2Content-Length: 190
3Content-Type: application/json;utf-8
4x-bce-request-id: 81d0b05f-5ad4-1f22-8068-d5c9de60a1d7
5Server: BCE-CDN
6
7{
8 "status": "ok",
9 "details": [
10 {
11 "timestamp": "2019-03-20T06:00:00Z",
12 "key": "cdaa.wonter.net",
13 "hitrate": 1
14 },
15 {
16 "timestamp": "2019-03-20T06:05:00Z",
17 "key": "cdaa.wonter.net",
18 "hitrate": 1
19 }
20 ],
21 "count": 2
22}
请求命中率查询
metric:pv_hit
响应体扩展字段:
参数 | 类型 | 说明 |
---|---|---|
hitrate | Double | 统计时间段内的pv命中率 |
请求示例
1POST /v2/stat/query HTTP/1.1
2Host: cdn.baidubce.com
3
4{
5 "metric": "pv_hit",
6 "startTime": "2019-03-20T06:00:00Z",
7 "endTime": "2019-03-20T06:10:00Z",
8 "period": 300,
9 "key_type": 0,
10 "key": [
11 "cdaa.wonter.net"
12 ],
13 "groupBy": "key"
14}
返回示例
1HTTP/1.1 200 OK
2Content-Length: 190
3Content-Type: application/json;utf-8
4x-bce-request-id: 81d0b05f-5ad4-1f22-8068-d5c9de60a1d7
5Server: BCE-CDN
6
7{
8 "status": "ok",
9 "details": [
10 {
11 "timestamp": "2019-03-20T06:00:00Z",
12 "key": "cdaa.wonter.net",
13 "hitrate": 1
14 },
15 {
16 "timestamp": "2019-03-20T06:05:00Z",
17 "key": "cdaa.wonter.net",
18 "hitrate": 1
19 }
20 ],
21 "count": 2
22}
状态码类接口
状态码统计查询
metric:httpcode
请求体扩展字段:
参数 | 可选 | 类型 | 说明 |
---|---|---|---|
level | 可选 | String | 支持查询边缘节点状态码。可填写all或edge,默认all |
protocol | 可选 | String | 查询的协议,可填写http3、all,默认all |
响应体扩展字段:
参数 | 类型 | 说明 |
---|---|---|
counters | list<KvCounter> | HTTP状态码计数 |
KvCounter内容
参数 | 类型 | 说明 |
---|---|---|
name | Long | HTTP状态码 |
count | Long | 统计计数 |
请求示例
1POST /v2/stat/query HTTP/1.1
2Host: cdn.baidubce.com
3
4{
5 "metric": "httpcode",
6 "startTime": "2019-03-20T06:00:00Z",
7 "endTime": "2019-03-20T06:10:00Z",
8 "period": 300,
9 "key_type": 0,
10 "key": [
11 "cdaa.wonter.net"
12 ],
13 "groupBy": "key"
14}
返回示例
1HTTP/1.1 200 OK
2Content-Length: 190
3Content-Type: application/json;utf-8
4x-bce-request-id: 81d0b05f-5ad4-1f22-8068-d5c9de60a1d7
5Server: BCE-CDN
6
7{
8 "status": "ok",
9 "details": [
10 {
11 "counters": [
12 {
13 "name": 200,
14 "count": 14205
15 },
16 {
17 "name": 499,
18 "count": 27
19 }
20 ],
21 "timestamp": "2019-03-20T06:00:00Z",
22 "key": "cdaa.wonter.net"
23 },
24 {
25 "counters": [
26 {
27 "name": 200,
28 "count": 14558
29 }
30 ],
31 "timestamp": "2019-03-20T06:05:00Z",
32 "key": "cdaa.wonter.net"
33 }
34 ],
35 "count": 2
36}
回源状态码查询
metric:src_httpcode
响应体扩展字段:
参数 | 类型 | 说明 |
---|---|---|
counters | list<KvCounter> | HTTP状态码计数 |
KvCounter内容
参数 | 类型 | 说明 |
---|---|---|
name | Long | HTTP状态码 |
count | Long | 统计计数 |
请求示例
1POST /v2/stat/query HTTP/1.1
2Host: cdn.baidubce.com
3
4{
5 "metric": "src_httpcode",
6 "startTime": "2019-03-20T06:00:00Z",
7 "endTime": "2019-03-20T06:10:00Z",
8 "period": 300,
9 "key_type": 0,
10 "key": [
11 "cdaa.wonter.net"
12 ],
13 "groupBy": "key"
14}
返回示例
1HTTP/1.1 200 OK
2Content-Length: 190
3Content-Type: application/json;utf-8
4x-bce-request-id: 81d0b05f-5ad4-1f22-8068-d5c9de60a1d7
5Server: BCE-CDN
6
7{
8 "status": "ok",
9 "details": [
10 {
11 "counters": [
12 {
13 "name": 200,
14 "count": 14205
15 },
16 {
17 "name": 499,
18 "count": 27
19 }
20 ],
21 "timestamp": "2019-03-20T06:00:00Z",
22 "key": "cdaa.wonter.net"
23 },
24 {
25 "counters": [
26 {
27 "name": 200,
28 "count": 14558
29 }
30 ],
31 "timestamp": "2019-03-20T06:05:00Z",
32 "key": "cdaa.wonter.net"
33 }
34 ],
35 "count": 2
36}
状态码统计查询(分客户端访问分布)
metric:httpcode_region
请求体扩展字段:
参数 | 可选 | 类型 | 说明 |
---|---|---|---|
prov | 可选 | String | 查询的省份全拼,默认为空,查询全国数据 |
isp | 可选 | String | 查询的运营商代码,默认为空,查询所有运营商数据 |
protocol | 可选 | String | 查询的协议,可填写http3、all,默认all |
响应体扩展字段:
参数 | 类型 | 说明 |
---|---|---|
distribution | list<HttpCodeDistributionData> | 按客户端访问地域分布的数据详情 |
HttpCodeDistributionData 内容
参数 | 类型 | 说明 |
---|---|---|
location | String | 客户端所在省份、地区 |
isp | String | 客户端所属运营商 |
counters | list<KvCounter> | HTTP状态码计数 |
KvCounter内容
参数 | 类型 | 说明 |
---|---|---|
name | Long | HTTP状态码 |
count | Long | 统计计数 |
请求示例
1POST /v2/stat/query HTTP/1.1
2Host: cdn.baidubce.com
3
4{
5 "metric": "httpcode_region",
6 "startTime": "2019-03-20T06:00:00Z",
7 "endTime": "2019-03-20T06:10:00Z",
8 "period": 300,
9 "key_type": 0,
10 "key": [
11 "cdaa.wonter.net"
12 ],
13 "groupBy": "key",
14 "prov": "beijing",
15 "isp": "ct"
16}
返回示例
1HTTP/1.1 200 OK
2Content-Length: 190
3Content-Type: application/json;utf-8
4x-bce-request-id: 81d0b05f-5ad4-1f22-8068-d5c9de60a1d7
5Server: BCE-CDN
6
7{
8 "status": "ok",
9 "details": [
10 {
11 "timestamp": "2019-03-20T06:00:00Z",
12 "key": "cdaa.wonter.net",
13 "distribution": [
14 {
15 "location": "北京",
16 "isp": "电信",
17 "counters": [
18 {
19 "name": 200,
20 "count": 137
21 }
22 ]
23 }
24 ]
25 },
26 {
27 "timestamp": "2019-03-20T06:05:00Z",
28 "key": "cdaa.wonter.net",
29 "distribution": [
30 {
31 "location": "北京",
32 "isp": "电信",
33 "counters": [
34 {
35 "name": 200,
36 "count": 141
37 }
38 ]
39 }
40 ]
41 }
42 ],
43 "count": 2
44}
TopN查询接口
注意:top数据查询时,groupBy参数无效,返回的都是聚合数据
TopN urls
metric:top_urls
请求体扩展字段:
参数 | 可选 | 类型 | 说明 |
---|---|---|---|
extra | 可选 | Long | 查询指定http状态码的记录,例如200,403,不传默认所有状态码 |
sortKey | 可选 | String | 值为pv或者flow,默认pv。表示返回的top数据的排序基准,例如取值pv,即所有请求按照pv排序后,取top,但是返回的数据并不是排序的 |
响应体扩展字段:
参数 | 类型 | 说明 |
---|---|---|
counters | list<TopNCounter> | 每小时Top200聚合 统计 |
total_pv | Long | 总pv |
total_flow | Long | 总流量 |
TopNCounter
参数 | 类型 | 说明 |
---|---|---|
name | String | url |
pv | Long | pv |
flow | Long | flow |
filesize | Long | 文件大小 单位byte |
filetype | String | 文件类型 url资源后缀 |
请求示例
1POST /v2/stat/query HTTP/1.1
2Host: cdn.baidubce.com
3
4{
5 "metric": "top_urls",
6 "startTime": "2023-08-01T00:00:00Z",
7 "endTime": "2023-08-01T01:00:00Z",
8 "period": 3600,
9 "key_type": 0,
10 "key": [
11 "baidu.com"
12 ]
13}
返回示例
1HTTP/1.1 200 OK
2Content-Length: 190
3Content-Type: application/json;utf-8
4x-bce-request-id: 81d0b05f-5ad4-1f22-8068-d5c9de60a1d7
5Server: BCE-CDN
6
7{
8 "status": "ok",
9 "details": [
10 {
11 "timestamp": "2023-08-01T00:00:00Z",
12 "key": "total",
13 "counters": [
14 {
15 "name": "https://baidu.com/1.txt",
16 "flow": 100,
17 "pv": 2,
18 "filetype": "txt",
19 "filesize": 3
20 },
21 {
22 "name": "https://baidu.com/2.txt",
23 "flow": 200,
24 "pv": 3,
25 "filetype": "txt",
26 "filesize": 3
27 }
28 ],
29 "total_pv": 5,
30 "total_flow": 300
31 }
32 ],
33 "count": 1
34}
TopN referers
metric:top_referers
请求体扩展字段:
参数 | 可选 | 类型 | 说明 |
---|---|---|---|
extra | 可选 | Long | 查询指定http状态码的记录,例如200,403,不传默认所有状态码 |
sortKey | 可选 | String | 值为pv或者flow,默认pv。表示返回的top数据的排序基准,例如取值pv,即所有请求按照pv排序后,取top,但是返回的数据并不是排序的 |
响应体扩展字段:
参数 | 类型 | 说明 |
---|---|---|
counters | list<TopNCounter> | Top100 统计 |
total_pv | Long | 总pv |
total_flow | Long | 总流量 |
TopNCounter
参数 | 类型 | 说明 |
---|---|---|
name | String | refer |
pv | Long | pv |
flow | Long | flow |
请求示例
1POST /v2/stat/query HTTP/1.1
2Host: cdn.baidubce.com
3
4{
5 "metric": "top_referers",
6 "startTime": "2023-08-01T00:00:00Z",
7 "endTime": "2023-08-01T01:00:00Z",
8 "period": 3600,
9 "key_type": 0,
10 "key": [
11 "baidu.com"
12 ]
13}
返回示例
1HTTP/1.1 200 OK
2Content-Length: 190
3Content-Type: application/json;utf-8
4x-bce-request-id: 81d0b05f-5ad4-1f22-8068-d5c9de60a1d7
5Server: BCE-CDN
6
7{
8 "status": "ok",
9 "details": [
10 {
11 "counters": [
12 {
13 "name": "baidu.com",
14 "flow": 2649952,
15 "pv": 21
16 }
17 ],
18 "timestamp": "2023-08-01T00:00:00Z",
19 "key": "total",
20 "total_pv": 21,
21 "total_flow": 2649952
22 }
23 ],
24 "count": 1
25}
TopN domains
metric:top_domains
请求体扩展字段:
参数 | 可选 | 类型 | 说明 |
---|---|---|---|
extra | 可选 | Long | 查询指定http状态码的记录,例如200,403,不传默认所有状态码 |
sortKey | 可选 | String | 值为pv或者flow,默认pv。表示返回的top数据的排序基准,例如取值pv,即所有请求按照pv排序后,取top,但是返回的数据并不是排序的 |
响应体扩展字段:
参数 | 类型 | 说明 |
---|---|---|
counters | list<TopNCounter> | Top100 统计 |
total_pv | Long | 总pv |
total_flow | Long | 总流量 |
TopNCounter
参数 | 类型 | 说明 |
---|---|---|
name | String | domains |
pv | Long | pv |
flow | Long | flow |
请求示例
1POST /v2/stat/query HTTP/1.1
2Host: cdn.baidubce.com
3
4{
5 "metric": "top_domains",
6 "startTime": "2023-08-01T07:00:00Z",
7 "endTime": "2023-08-01T08:00:00Z",
8 "period": 3600,
9 "key": [
10 "your user id"
11 ],
12 "key_type": 1
13}
返回示例
1HTTP/1.1 200 OK
2Content-Length: 190
3Content-Type: application/json;utf-8
4x-bce-request-id: 81d0b05f-5ad4-1f22-8068-d5c9de60a1d7
5Server: BCE-CDN
6
7{
8 "status": "ok",
9 "details": [
10 {
11 "counters": [
12 {
13 "name": "www.baidu.com",
14 "flow": 75385,
15 "pv": 119
16 },
17 {
18 "name": "test.baidu.com",
19 "flow": 6780,
20 "pv": 13
21 },
22 {
23 "name": "baidu.com",
24 "flow": 6705,
25 "pv": 18
26 }
27 ],
28 "timestamp": "2023-08-01T07:00:00Z",
29 "key": "total",
30 "total_pv": 150,
31 "total_flow": 88870
32 }
33 ],
34 "count": 1
35}
TopN clientIP
metric:top_clientip
请求体扩展字段:
参数 | 可选 | 类型 | 说明 |
---|---|---|---|
extra | 可选 | Long | 查询指定http状态码的记录,例如200,403,不传默认所有状态码 |
sortKey | 可选 | String | 值为pv或者flow,默认pv。表示返回的top数据的排序基准,例如取值pv,即所有请求按照pv排序后,取top,但是返回的数据并不是排序的 |
响应体扩展字段:
参数 | 类型 | 说明 |
---|---|---|
counters | list<TopNCounter> | Top100 统计 |
total_pv | Long | 总pv |
total_flow | Long | 总流量 |
TopNCounter
参数 | 类型 | 说明 |
---|---|---|
name | String | ip |
pv | Long | pv |
flow | Long | flow |
请求示例
1POST /v2/stat/query HTTP/1.1
2Host: cdn.baidubce.com
3
4{
5 "metric": "top_clientip",
6 "startTime": "2023-08-01T07:00:00Z",
7 "endTime": "2023-08-01T08:00:00Z",
8 "period": 3600,
9 "key": [
10 "your user id"
11 ],
12 "key_type": 1
13}
返回示例
1HTTP/1.1 200 OK
2Content-Length: 190
3Content-Type: application/json;utf-8
4x-bce-request-id: 81d0b05f-5ad4-1f22-8068-d5c9de60a1d7
5Server: BCE-CDN
6
7{
8 "status": "ok",
9 "details": [
10 {
11 "counters": [
12 {
13 "name": "87.236.176.0",
14 "flow": 2640611,
15 "pv": 1
16 },
17 {
18 "name": "111.206.214.32",
19 "flow": 9341,
20 "pv": 20
21 }
22 ],
23 "timestamp": "2023-08-01T07:00:00Z",
24 "key": "total",
25 "total_pv": 21,
26 "total_flow": 2649952
27 }
28 ],
29 "count": 1
30}
查询 IPV6 数据接口
method | path | 说明 |
---|---|---|
post | /v2/stat/ipv6?stat_type=http/https/all | 查询ipv6的统计,stat_type 表查询的数据类型,值为为 http 时表查询的 http 数据;值为 https 时表查询的 https 的数据;值为 all 时表查询的包含http,https的总数据;值为region时表示查询分省份-运营商的数据;默认查询all |
请求体(Request Body)
参数 | 可选 | 类型 | 说明 |
---|---|---|---|
startTime | 可选 | Timestamp | 查询的时间范围起始值,默认为endTime前推24小时 UTC时间 |
endTime | 可选 | Timestamp | 查询的时间范围结束值,默认为当前时间。时间跨度最长90天 UTC时间 |
period | 可选 | int | 查询的时间粒度,单位为s,默认值为 300s |
keys | 可选 | list |
查询的域名列表,当该列表为空是查询该用户的所有域名的数据 |
prov | 可选 | string | 查询的省份拼音全拼,默认为空,查询全国数据,仅当stat_type为region表示查询ipv6分区域数据时此值有效 |
isp | 可选 | string | 查询的运营商代码,默认为空,查询所有运营商数据,仅当stat_type为region表示查询ipv6分区域数据时此值有效 |
响应体(Request Body)
参数 | 可选 | 类型 | 说明 |
---|---|---|---|
details | 必选 | map<timesmap:map<domain:Data>> | 查询结果,其中 timesmap 为 UTC 格式时间,domain 为域名或者 userId。Data 为某个时间点某个域名/用户的数据 |
count | 必选 | int | 查询到到数据条数 |
Data 类型说明:
参数 | 可选 | 类型 | 说明 |
---|---|---|---|
flow | 必选 | int | 查询的流量数据 |
bps | 可选 | int | 查询的带宽数据,仅当stat_type不为region时此值有效 |
pv | 必选 | int | 查询的pv数据 |
code | 可选 | list<map<int: int> | 查询的code码数据,仅当stat_type不为region时此值有效 |
distribution | 可选 | map<string, string> | 区域信息,仅当stat_type为region时此值有效,示例数据:{"location":"广东", "isp": "电信"} |
请求示例 1:查询某个域名的全局ipv6统计
1POST /v2/stat/ipv6?stat_type=all
2Host: cdn.baidubce.com
3{
4 "startTime": "2020-12-21T06:25:00Z",
5 "endTime": "2020-12-21T07:25:00Z",
6 "period": 3600,
7 "keys": [
8 "www.example.com"
9 ]
10}
响应示例 1
1{
2 "count": 3,
3 "details": {
4 "2020-12-21T06:00:00Z": {
5 "www.example.com": {
6 "flow": 822846778444,
7 "bps": 1828548396,
8 "pv": 5953881,
9 "code": {
10 "200": 5718978,
11 "206": 4888,
12 "304": 230015,
13 "400": 37,
14 "403": 77,
15 "404": 64,
16 "408": 19,
17 "499": 15810
18 }
19 }
20 },
21 "2020-12-21T07:00:00Z": {
22 "www.example.com": {
23 "flow": 794698943871,
24 "bps": 1765997653,
25 "pv": 5995772,
26 "code": {
27 "200": 5733844,
28 "206": 4908,
29 "304": 257020,
30 "400": 32,
31 "403": 57,
32 "404": 42,
33 "408": 17,
34 "499": 16057
35 }
36 }
37 },
38 "2020-12-21T08:00:00Z": {
39 "www.example.com": {
40 "flow": 767797627279,
41 "bps": 1706216949,
42 "pv": 6043410,
43 "code": {
44 "200": 5790261,
45 "206": 4893,
46 "304": 248256,
47 "400": 31,
48 "403": 81,
49 "404": 32,
50 "408": 15,
51 "416": 1,
52 "499": 15975
53 }
54 }
55 }
56 }
57}
请求示例 2:查询某2个域名在广东电信区域的ipv6统计
1POST /v2/stat/ipv6?stat_type=region
2Host: cdn.baidubce.com
3{
4 "startTime":"2021-08-31T10:00:00Z",
5 "endTime":"2021-08-31T10:10:00Z",
6 "keys":[
7 "www.example.com",
8 "www.test.com"
9 ],
10 "period":300,
11 "isp":"ct",
12 "prov":"guangdong"
13}
响应示例 2
1{
2 "count":3,
3 "details":{
4 "2021-08-31T10:10:00Z":{
5 "www.example.com":[
6 {
7 "flow":2329321827,
8 "pv":873,
9 "distribution":{
10 "location":"广东",
11 "isp":"电信"
12 }
13 }
14 ],
15 "www.test.com":[
16 {
17 "flow":3460533,
18 "pv":156,
19 "distribution":{
20 "location":"广东",
21 "isp":"电信"
22 }
23 }
24 ]
25 },
26 "2021-08-31T10:05:00Z":{
27 "www.example.com":[
28 {
29 "flow":4975040172,
30 "pv":2570,
31 "distribution":{
32 "location":"广东",
33 "isp":"电信"
34 }
35 }
36 ],
37 "www.test.com":[
38 {
39 "flow":50829586,
40 "pv":1400,
41 "distribution":{
42 "location":"广东",
43 "isp":"电信"
44 }
45 }
46 ]
47 },
48 "2021-08-31T10:00:00Z":{
49 "www.example.com":[
50 {
51 "flow":11245259964,
52 "pv":3735,
53 "distribution":{
54 "location":"广东",
55 "isp":"电信"
56 }
57 }
58 ],
59 "www.test.com":[
60 {
61 "flow":37659121,
62 "pv":1119,
63 "distribution":{
64 "location":"广东",
65 "isp":"电信"
66 }
67 }
68 ]
69 }
70 }
71}
cdn错误码分类统计查询
metric:error
响应体扩展字段:
参数 | 类型 | 说明 |
---|---|---|
counters | list<KvCounter> | 错误状态码类型及对应计数 |
KvCounter内容
参数 | 类型 | 说明 |
---|---|---|
code | String | 错误码 |
counters | list<DetailData> | 错误类型及计数 |
DetailData 内容
参数 | 类型 | 说明 |
---|---|---|
name | String | 错误类型 |
count | Long | 统计计数 |
请求示例
1POST /v2/stat/query HTTP/1.1
2Host: cdn.baidubce.com
3
4{
5 "metric": "error",
6 "startTime": "2019-03-20T06:00:00Z",
7 "endTime": "2019-03-20T06:10:00Z",
8 "period": 300,
9 "key_type": 0,
10 "key": [
11 "cdaa.wonter.net"
12 ],
13 "groupBy": "key"
14}
返回示例
1HTTP/1.1 200 OK
2Content-Length: 190
3Content-Type: application/json;utf-8
4x-bce-request-id: 81d0b05f-5ad4-1f22-8068-d5c9de60a1d7
5Server: BCE-CDN
6
7{
8 "status": "ok",
9 "details": [
10 {
11 "timestamp": "2019-03-20T06:00:00Z",
12 "key": "cdaa.wonter.net",
13 "counters": [
14 {
15 "code": 499,
16 "counters": [
17 {
18 "name": "未知",
19 "count": 27
20 }
21 ]
22 }
23 ]
24 },
25 {
26 "timestamp": "2019-03-20T06:05:00Z",
27 "key": "cdaa.wonter.net",
28 "counters": [
29 {
30 "code": 499,
31 "counters": [
32 {
33 "name": "未知",
34 "count": 18
35 }
36 ]
37 }
38 ]
39 }
40 ],
41 "count": 2
42}
错误类型分类
名称 | 备注 |
---|---|
源站错误 | 4xx和5xx |
源站错误,CDN已缓存 | 4xx和5xx |
CDN错误 | 4xx和5xx |
未命中499 | 499 |
命中499 | 499 |
CDN连接源站读超时 | 5xx |
CDN连接源站失败 | 5xx |
CDN连接源站失败(SSL) | 5xx |
CDN解析源站域名失败 | 5xx |
CDN与源站交互失败 | 5xx |
未知 | 未匹配到的错误类型 |