统计接口(新)
更新时间: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生效,详见测试用例。
平均速率
查询平均速率
public function testGetDomainStatsAvgSpeed() {
$statParam = array(
'startTime' => '2019-05-26T00:00:00Z',
'endTime' => '2019-05-27T00:00:00Z',
'period' => 300,
'key_type' => 0,
'key' => array('test-sdk.sys-qa.com'),
'groupBy' => '',
'metric' => 'avg_speed',
);
$resp = $this->client->getDomainStats($statParam);
$this->assertNotNull($resp);
}
查询按客户端访问分布的平均速率
public function testGetDomainStatsAvgSpeedRegion() {
$statParam = array(
'startTime' => '2019-05-26T00:00:00Z',
'endTime' => '2019-05-27T00:00:00Z',
'period' => 300,
'key_type' => 0,
'key' => array('test-sdk.sys-qa.com'),
'groupBy' => '',
'prov' => 'beijing',
'isp' => 'ct',
'metric' => 'avg_speed_region',
);
$resp = $this->client->getDomainStats($statParam);
$this->assertNotNull($resp);
}
pv/qps相关数据查询
查询pv/qps
public function testGetDomainStatsPv() {
$statParam = array(
'startTime' => '2019-05-26T00:00:00Z',
'endTime' => '2019-05-27T00:00:00Z',
'period' => 300,
'key_type' => 0,
'key' => array('test-sdk.sys-qa.com'),
'groupBy' => '',
'level' => 'edge',
'metric' => 'pv',
);
$resp = $this->client->getDomainStats($statParam);
$this->assertNotNull($resp);
}
查询按客户端访问分布的pv/qps
public function testGetDomainStatsPvRegion() {
$statParam = array(
'startTime' => '2019-05-26T00:00:00Z',
'endTime' => '2019-05-27T00:00:00Z',
'period' => 300,
'key_type' => 0,
'key' => array('test-sdk.sys-qa.com'),
'groupBy' => '',
'prov' => 'beijing',
'isp' => 'ct',
'metric' => 'pv_region',
);
$resp = $this->client->getDomainStats($statParam);
$this->assertNotNull($resp);
}
查询回源pv/qps
public function testGetDomainStatsPvSrc() {
$statParam = array(
'startTime' => '2019-05-26T00:00:00Z',
'endTime' => '2019-05-27T00:00:00Z',
'period' => 300,
'key_type' => 0,
'key' => array('test-sdk.sys-qa.com'),
'groupBy' => '',
'metric' => 'pv_src',
);
$resp = $this->client->getDomainStats($statParam);
$this->assertNotNull($resp);
}
查询UV
public function testGetDomainStatsUv() {
$statParam = array(
'startTime' => '2019-05-26T00:00:00Z',
'endTime' => '2019-05-27T00:00:00Z',
'period' => 3600,
'key_type' => 0,
'key' => array('test-sdk.sys-qa.com'),
'groupBy' => '',
'metric' => 'uv',
);
$resp = $this->client->getDomainStats($statParam);
$this->assertNotNull($resp);
}
流量带宽相关查询
查询流量带宽
public function testGetDomainStatsFlow() {
$statParam = array(
'startTime' => '2019-05-26T00:00:00Z',
'endTime' => '2019-05-27T00:00:00Z',
'period' => 300,
'key_type' => 0,
'key' => array('test-sdk.sys-qa.com'),
'groupBy' => '',
'level' => 'edge',
'metric' => 'flow',
);
$resp = $this->client->getDomainStats($statParam);
$this->assertNotNull($resp);
}
查询分协议的流量带宽
public function testGetDomainStatsFlowProtocol() {
$statParam = array(
'startTime' => '2019-05-26T00:00:00Z',
'endTime' => '2019-05-27T00:00:00Z',
'period' => 300,
'key_type' => 0,
'key' => array('test-sdk.sys-qa.com'),
'groupBy' => '',
'protocol' => 'https',
'metric' => 'flow_protocol',
);
$resp = $this->client->getDomainStats($statParam);
$this->assertNotNull($resp);
}
查询分省份运营商的流量带宽
public function testGetDomainStatsFLowRegion() {
$statParam = array(
'startTime' => '2019-05-26T00:00:00Z',
'endTime' => '2019-05-27T00:00:00Z',
'period' => 300,
'key_type' => 0,
'key' => array('test-sdk.sys-qa.com'),
'groupBy' => '',
'prov' => 'beijing',
'isp' => 'ct',
'metric' => 'flow_region',
);
$resp = $this->client->getDomainStats($statParam);
$this->assertNotNull($resp);
}
查询回源流量带宽
public function testGetDomainStatsFlowSrc() {
$statParam = array(
'startTime' => '2019-05-26T00:00:00Z',
'endTime' => '2019-05-27T00:00:00Z',
'period' => 300,
'key_type' => 0,
'key' => array('test-sdk.sys-qa.com'),
'groupBy' => '',
'metric' => 'src_flow',
);
$resp = $this->client->getDomainStats($statParam);
$this->assertNotNull($resp);
}
命中率相关
查询字节命中率
public function testGetDomainStatsHit() {
$statParam = array(
'startTime' => '2019-05-26T00:00:00Z',
'endTime' => '2019-05-27T00:00:00Z',
'period' => 300,
'key_type' => 0,
'key' => array('test-sdk.sys-qa.com'),
'groupBy' => '',
'metric' => 'real_hit',
);
$resp = $this->client->getDomainStats($statParam);
$this->assertNotNull($resp);
}
查询请求命中率
public function testGetDomainStatsHitPv() {
$statParam = array(
'startTime' => '2019-05-26T00:00:00Z',
'endTime' => '2019-05-27T00:00:00Z',
'period' => 300,
'key_type' => 0,
'key' => array('test-sdk.sys-qa.com'),
'groupBy' => '',
'metric' => 'pv_hit',
);
$resp = $this->client->getDomainStats($statParam);
$this->assertNotNull($resp);
}
状态码相关
状态码统计查询
public function testGetDomainStatsHttpCode() {
$statParam = array(
'startTime' => '2019-05-26T00:00:00Z',
'endTime' => '2019-05-27T00:00:00Z',
'period' => 300,
'key_type' => 0,
'key' => array('test-sdk.sys-qa.com'),
'groupBy' => '',
'metric' => 'httpcode',
);
$resp = $this->client->getDomainStats($statParam);
$this->assertNotNull($resp);
}
回源状态码查询
public function testGetDomainStatsHttpCodeSrc() {
$statParam = array(
'startTime' => '2019-05-26T00:00:00Z',
'endTime' => '2019-05-27T00:00:00Z',
'period' => 300,
'key_type' => 0,
'key' => array('test-sdk.sys-qa.com'),
'groupBy' => '',
'metric' => 'src_httpcode',
);
$resp = $this->client->getDomainStats($statParam);
$this->assertNotNull($resp);
}
分省份运营商的状态码查询
public function testGetDomainStatsHttpCodeRegion() {
$statParam = array(
'startTime' => '2019-05-26T00:00:00Z',
'endTime' => '2019-05-27T00:00:00Z',
'period' => 300,
'key_type' => 0,
'key' => array('test-sdk.sys-qa.com'),
'groupBy' => '',
'prov' => 'beijing',
'isp' => 'ct',
'metric' => 'httpcode_region',
);
$resp = $this->client->getDomainStats($statParam);
$this->assertNotNull($resp);
}
Top N 查询
Top Urls
public function testGetDomainStatsTopUrls() {
$statParam = array(
'startTime' => '2019-05-26T00:00:00Z',
'endTime' => '2019-05-27T00:00:00Z',
'period' => 300,
'key_type' => 0,
'key' => array('test-sdk.sys-qa.com'),
'groupBy' => '',
'extra' => 200,
'metric' => 'top_urls',
);
$resp = $this->client->getDomainStats($statParam);
$this->assertNotNull($resp);
}
Top Referers
public function testGetDomainStatsTopReferers() {
$statParam = array(
'startTime' => '2019-05-26T00:00:00Z',
'endTime' => '2019-05-27T00:00:00Z',
'period' => 300,
'key_type' => 0,
'key' => array('test-sdk.sys-qa.com'),
'groupBy' => '',
'extra' => 200,
'metric' => 'top_referers',
);
$resp = $this->client->getDomainStats($statParam);
$this->assertNotNull($resp);
}
Top Domains
public function testGetDomainStatsTopDomains() {
$statParam = array(
'startTime' => '2019-05-26T00:00:00Z',
'endTime' => '2019-05-27T00:00:00Z',
'period' => 300,
'groupBy' => '',
'extra' => 200,
'metric' => 'top_domains',
);
$resp = $this->client->getDomainStats($statParam);
$this->assertNotNull($resp);
}
错误状态码原因查询
public function testGetDomainStatsError() {
$statParam = array(
'startTime' => '2019-05-26T00:00:00Z',
'endTime' => '2019-05-27T00:00:00Z',
'period' => 300,
'key_type' => 0,
'key' => array('test-sdk.sys-qa.com'),
'groupBy' => '',
'metric' => 'error',
);
$resp = $this->client->getDomainStats($statParam);
$this->assertNotNull($resp);
}