统计接口(新)
更新时间:2023-05-16
新版统计接口采用统一入口查询,各个数据项的查询通过参数进行区分。
参数说明:
参数 | 可选 | 类型 | 说明 | 生效范围 |
---|---|---|---|---|
metric | 必选 | String | 指定查询的统计维度,例如pv、pv_region、flow等 | - |
end_time | 可选 | String | 查询的时间范围结束值,默认为当前时间。时间跨度最长90天 | ALL |
start_time | 可选 | String | 查询的时间范围起始值,默认为endTime前推24小时 | ALL |
period | 可选 | Long | 查询粒度,单位秒,可选值为60,300,3600,86400;默认为300,uv 默认3600 | ALL |
key_type | 可选 | Long | 标识key的内容,0=>域名,1=>用户id,2=>tag,默认0 | ALL |
key | 可选 | list |
域名或用户Id或Tag | ALL |
groupBy | 可选 | String | 返回结果聚合粒度,key => 根据key聚合,空 => 返回整体结果 | ALL |
level | 可选 | String | 全节点(all)、边缘(edge) 或者 内部(internal),默认all | pv、flow |
prov | 可选 | String | 查询的省份全拼,默认为空,查询全国数据。 | region相关 |
isp | 可选 | String | 查询的运营商代码,默认为空,查询所有运营商数据。 | region相关 |
protocol | 可选 | String | 查询http或https的流量、带宽, 取值{'http', 'https', 'all'},默认‘all’ | flow_protocol |
extra | 可选 | Long | 查询指定http状态码的记录,默认值:"" | top n 相关 |
备注:
生效范围指某些参数针对所有的metric生效,某些参数针对部分metric生效,详见测试用例。
平均速率
查询平均速率
Plain Text
1public function testGetDomainStatsAvgSpeed() {
2 $statParam = array(
3 'startTime' => '2019-05-26T00:00:00Z',
4 'endTime' => '2019-05-27T00:00:00Z',
5 'period' => 300,
6 'key_type' => 0,
7 'key' => array('test-sdk.sys-qa.com'),
8 'groupBy' => '',
9 'metric' => 'avg_speed',
10 );
11
12 $resp = $this->client->getDomainStats($statParam);
13 $this->assertNotNull($resp);
14}
查询按客户端访问分布的平均速率
Plain Text
1public function testGetDomainStatsAvgSpeedRegion() {
2 $statParam = array(
3 'startTime' => '2019-05-26T00:00:00Z',
4 'endTime' => '2019-05-27T00:00:00Z',
5 'period' => 300,
6 'key_type' => 0,
7 'key' => array('test-sdk.sys-qa.com'),
8 'groupBy' => '',
9 'prov' => 'beijing',
10 'isp' => 'ct',
11 'metric' => 'avg_speed_region',
12 );
13
14 $resp = $this->client->getDomainStats($statParam);
15 $this->assertNotNull($resp);
16}
pv/qps相关数据查询
查询pv/qps
Plain Text
1public function testGetDomainStatsPv() {
2 $statParam = array(
3 'startTime' => '2019-05-26T00:00:00Z',
4 'endTime' => '2019-05-27T00:00:00Z',
5 'period' => 300,
6 'key_type' => 0,
7 'key' => array('test-sdk.sys-qa.com'),
8 'groupBy' => '',
9 'level' => 'edge',
10 'metric' => 'pv',
11 );
12
13 $resp = $this->client->getDomainStats($statParam);
14 $this->assertNotNull($resp);
15}
查询按客户端访问分布的pv/qps
Plain Text
1public function testGetDomainStatsPvRegion() {
2 $statParam = array(
3 'startTime' => '2019-05-26T00:00:00Z',
4 'endTime' => '2019-05-27T00:00:00Z',
5 'period' => 300,
6 'key_type' => 0,
7 'key' => array('test-sdk.sys-qa.com'),
8 'groupBy' => '',
9 'prov' => 'beijing',
10 'isp' => 'ct',
11 'metric' => 'pv_region',
12 );
13
14 $resp = $this->client->getDomainStats($statParam);
15 $this->assertNotNull($resp);
16}
查询回源pv/qps
Plain Text
1public function testGetDomainStatsPvSrc() {
2 $statParam = array(
3 'startTime' => '2019-05-26T00:00:00Z',
4 'endTime' => '2019-05-27T00:00:00Z',
5 'period' => 300,
6 'key_type' => 0,
7 'key' => array('test-sdk.sys-qa.com'),
8 'groupBy' => '',
9 'metric' => 'pv_src',
10 );
11
12 $resp = $this->client->getDomainStats($statParam);
13 $this->assertNotNull($resp);
14}
查询UV
Plain Text
1public function testGetDomainStatsUv() {
2 $statParam = array(
3 'startTime' => '2019-05-26T00:00:00Z',
4 'endTime' => '2019-05-27T00:00:00Z',
5 'period' => 3600,
6 'key_type' => 0,
7 'key' => array('test-sdk.sys-qa.com'),
8 'groupBy' => '',
9 'metric' => 'uv',
10 );
11
12 $resp = $this->client->getDomainStats($statParam);
13 $this->assertNotNull($resp);
14}
流量带宽相关查询
查询流量带宽
Plain Text
1public function testGetDomainStatsFlow() {
2 $statParam = array(
3 'startTime' => '2019-05-26T00:00:00Z',
4 'endTime' => '2019-05-27T00:00:00Z',
5 'period' => 300,
6 'key_type' => 0,
7 'key' => array('test-sdk.sys-qa.com'),
8 'groupBy' => '',
9 'level' => 'edge',
10 'metric' => 'flow',
11 );
12
13 $resp = $this->client->getDomainStats($statParam);
14 $this->assertNotNull($resp);
15}
查询分协议的流量带宽
Plain Text
1public function testGetDomainStatsFlowProtocol() {
2 $statParam = array(
3 'startTime' => '2019-05-26T00:00:00Z',
4 'endTime' => '2019-05-27T00:00:00Z',
5 'period' => 300,
6 'key_type' => 0,
7 'key' => array('test-sdk.sys-qa.com'),
8 'groupBy' => '',
9 'protocol' => 'https',
10 'metric' => 'flow_protocol',
11 );
12
13 $resp = $this->client->getDomainStats($statParam);
14 $this->assertNotNull($resp);
15}
查询分省份运营商的流量带宽
Plain Text
1public function testGetDomainStatsFLowRegion() {
2 $statParam = array(
3 'startTime' => '2019-05-26T00:00:00Z',
4 'endTime' => '2019-05-27T00:00:00Z',
5 'period' => 300,
6 'key_type' => 0,
7 'key' => array('test-sdk.sys-qa.com'),
8 'groupBy' => '',
9 'prov' => 'beijing',
10 'isp' => 'ct',
11 'metric' => 'flow_region',
12 );
13
14 $resp = $this->client->getDomainStats($statParam);
15 $this->assertNotNull($resp);
16}
查询回源流量带宽
Plain Text
1public function testGetDomainStatsFlowSrc() {
2 $statParam = array(
3 'startTime' => '2019-05-26T00:00:00Z',
4 'endTime' => '2019-05-27T00:00:00Z',
5 'period' => 300,
6 'key_type' => 0,
7 'key' => array('test-sdk.sys-qa.com'),
8 'groupBy' => '',
9 'metric' => 'src_flow',
10 );
11
12 $resp = $this->client->getDomainStats($statParam);
13 $this->assertNotNull($resp);
14}
命中率相关
查询字节命中率
Plain Text
1public function testGetDomainStatsHit() {
2 $statParam = array(
3 'startTime' => '2019-05-26T00:00:00Z',
4 'endTime' => '2019-05-27T00:00:00Z',
5 'period' => 300,
6 'key_type' => 0,
7 'key' => array('test-sdk.sys-qa.com'),
8 'groupBy' => '',
9 'metric' => 'real_hit',
10 );
11
12 $resp = $this->client->getDomainStats($statParam);
13 $this->assertNotNull($resp);
14}
查询请求命中率
Plain Text
1public function testGetDomainStatsHitPv() {
2 $statParam = array(
3 'startTime' => '2019-05-26T00:00:00Z',
4 'endTime' => '2019-05-27T00:00:00Z',
5 'period' => 300,
6 'key_type' => 0,
7 'key' => array('test-sdk.sys-qa.com'),
8 'groupBy' => '',
9 'metric' => 'pv_hit',
10 );
11
12 $resp = $this->client->getDomainStats($statParam);
13 $this->assertNotNull($resp);
14}
状态码相关
状态码统计查询
Plain Text
1public function testGetDomainStatsHttpCode() {
2 $statParam = array(
3 'startTime' => '2019-05-26T00:00:00Z',
4 'endTime' => '2019-05-27T00:00:00Z',
5 'period' => 300,
6 'key_type' => 0,
7 'key' => array('test-sdk.sys-qa.com'),
8 'groupBy' => '',
9 'metric' => 'httpcode',
10 );
11
12 $resp = $this->client->getDomainStats($statParam);
13 $this->assertNotNull($resp);
14}
回源状态码查询
Plain Text
1public function testGetDomainStatsHttpCodeSrc() {
2 $statParam = array(
3 'startTime' => '2019-05-26T00:00:00Z',
4 'endTime' => '2019-05-27T00:00:00Z',
5 'period' => 300,
6 'key_type' => 0,
7 'key' => array('test-sdk.sys-qa.com'),
8 'groupBy' => '',
9 'metric' => 'src_httpcode',
10 );
11
12 $resp = $this->client->getDomainStats($statParam);
13 $this->assertNotNull($resp);
14}
分省份运营商的状态码查询
Plain Text
1public function testGetDomainStatsHttpCodeRegion() {
2 $statParam = array(
3 'startTime' => '2019-05-26T00:00:00Z',
4 'endTime' => '2019-05-27T00:00:00Z',
5 'period' => 300,
6 'key_type' => 0,
7 'key' => array('test-sdk.sys-qa.com'),
8 'groupBy' => '',
9 'prov' => 'beijing',
10 'isp' => 'ct',
11 'metric' => 'httpcode_region',
12 );
13
14 $resp = $this->client->getDomainStats($statParam);
15 $this->assertNotNull($resp);
16}
Top N 查询
Top Urls
Plain Text
1public function testGetDomainStatsTopUrls() {
2 $statParam = array(
3 'startTime' => '2019-05-26T00:00:00Z',
4 'endTime' => '2019-05-27T00:00:00Z',
5 'period' => 300,
6 'key_type' => 0,
7 'key' => array('test-sdk.sys-qa.com'),
8 'groupBy' => '',
9 'extra' => 200,
10 'metric' => 'top_urls',
11 );
12
13 $resp = $this->client->getDomainStats($statParam);
14 $this->assertNotNull($resp);
15}
Top Referers
Plain Text
1public function testGetDomainStatsTopReferers() {
2 $statParam = array(
3 'startTime' => '2019-05-26T00:00:00Z',
4 'endTime' => '2019-05-27T00:00:00Z',
5 'period' => 300,
6 'key_type' => 0,
7 'key' => array('test-sdk.sys-qa.com'),
8 'groupBy' => '',
9 'extra' => 200,
10 'metric' => 'top_referers',
11 );
12
13 $resp = $this->client->getDomainStats($statParam);
14 $this->assertNotNull($resp);
15}
Top Domains
Plain Text
1public function testGetDomainStatsTopDomains() {
2 $statParam = array(
3 'startTime' => '2019-05-26T00:00:00Z',
4 'endTime' => '2019-05-27T00:00:00Z',
5 'period' => 300,
6 'groupBy' => '',
7 'extra' => 200,
8 'metric' => 'top_domains',
9 );
10
11 $resp = $this->client->getDomainStats($statParam);
12 $this->assertNotNull($resp);
13}
错误状态码原因查询
Plain Text
1public function testGetDomainStatsError() {
2 $statParam = array(
3 'startTime' => '2019-05-26T00:00:00Z',
4 'endTime' => '2019-05-27T00:00:00Z',
5 'period' => 300,
6 'key_type' => 0,
7 'key' => array('test-sdk.sys-qa.com'),
8 'groupBy' => '',
9 'metric' => 'error',
10 );
11
12 $resp = $this->client->getDomainStats($statParam);
13 $this->assertNotNull($resp);
14}