内容分发网络CDN

    统计接口(新版)

    新建查询参数

    CdnStatsParam为统计相关接口的查询参数类,用户可参考如下代码新建一个CdnStatsParam:

    CdnStatsParam(start_time='2019-05-26T00:00:00Z', end_time='2019-05-26T01:00:00Z', key_type=0,
                        key=['opencdn3.sys-qa.com'], period=300, groupBy='')

    参数说明:

    参数 可选 类型 说明 生效范围
    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生效,详见测试用例。

    平均速率

    查询平均速率

    def test_get_domain_stats_avg_speed(c):
        """
        test_get_domain_stats_avg_speed
        """
        param = CdnStatsParam(start_time='2019-05-26T00:00:00Z', end_time='2019-05-26T01:00:00Z', key_type=0,
                              key=['opencdn3.sys-qa.com'], period=300, groupBy='')
        param.metric = 'avg_speed'
        response = c.get_domain_stats(param)
        print(response)

    查询按客户端访问分布的平均速率

    def test_get_domain_stats_avg_speed_region(c):
        """
        test_get_domain_stats_avg_speed_region
        """
        param = CdnStatsParam(start_time='2019-05-26T00:00:00Z', end_time='2019-05-26T01:00:00Z', key_type=None,
                              key=['opencdn3.sys-qa.com'], period=300, groupBy='')
        param.metric = 'avg_speed_region'
        param.prov = 'beijing'
        param.isp = 'ct'
        response = c.get_domain_stats(param)
        print(response)

    pv/qps相关数据查询

    查询pv/qps

    def test_get_domain_stats_pv(c):
        """
        test_get_domain_stats_pv
        """
        param = CdnStatsParam(start_time='2019-05-26T00:00:00Z', end_time='2019-05-26T01:00:00Z', key_type=0,
                              key=['opencdn3.sys-qa.com'], period=300, groupBy='')
        param.metric = 'pv'
        param.level = 'edge'
        response = c.get_domain_stats(param)
        print(response)

    查询按客户端访问分布的pv/qps

    def test_get_domain_stats_pv_region(c):
        """
        test_get_domain_stats_pv_region
        """
        param = CdnStatsParam(start_time='2019-05-26T00:00:00Z', end_time='2019-05-26T01:00:00Z', key_type=0,
                              key=['opencdn3.sys-qa.com'], period=300, groupBy='')
        param.metric = 'pv_region'
        param.prov = 'beijing'
        param.isp = 'ct'
        response = c.get_domain_stats(param)
        print(response)

    查询回源pv/qps

    def test_get_domain_stats_pv_src(c):
        """
        test_get_domain_stats_pv_src
        """
        param = CdnStatsParam(start_time='2019-05-26T00:00:00Z', end_time='2019-05-26T01:00:00Z', key_type=0,
                              key=['opencdn3.sys-qa.com'], period=300, groupBy='')
        param.metric = 'pv_src'
        response = c.get_domain_stats(param)
        print(response)

    查询UV

    def test_get_domain_stats_uv(c):
        """
        test_get_domain_stats_uv
        """
        param = CdnStatsParam(start_time='2019-05-25T00:00:00Z', end_time='2019-05-26T00:00:00Z', key_type=0,
                              key=['opencdn3.sys-qa.com'], period=3600, groupBy='')
        param.metric = 'uv'
        response = c.get_domain_stats(param)
        print(response)

    流量带宽相关查询

    查询流量带宽

    def test_get_domain_stats_flow(c):
        """
        test_get_domain_stats_flow
        """
        param = CdnStatsParam(start_time='2019-05-26T00:00:00Z', end_time='2019-05-26T01:00:00Z', key_type=0,
                              key=['opencdn3.sys-qa.com'], period=300, groupBy='')
        param.metric = 'flow'
        param.level = 'edge'
        response = c.get_domain_stats(param)
        print(response)

    查询分协议的流量带宽

    def test_get_domain_stats_flow_protocol(c):
        """
        test_get_domain_stats_flow_protocol
        """
        param = CdnStatsParam(start_time='2019-05-26T00:00:00Z', end_time='2019-05-26T01:00:00Z', key_type=0,
                              key=['opencdn3.sys-qa.com'], period=300, groupBy='')
        param.metric = 'flow_protocol'
        param.protocol = 'http'
        response = c.get_domain_stats(param)
        print(response)

    查询分省份运营商的流量带宽

    def test_get_domain_stats_flow_region(c):
        """
        test_get_domain_stats_flow_region
        """
        param = CdnStatsParam(start_time='2019-05-26T00:00:00Z', end_time='2019-05-26T01:00:00Z', key_type=0,
                              key=['opencdn3.sys-qa.com'], period=300, groupBy='')
        param.metric = 'flow_region'
        param.prov = 'beijing'
        param.isp = 'ct'
        response = c.get_domain_stats(param)
        print(response)

    查询回源流量带宽

    def test_get_domain_stats_src_flow(c):
        """
        test_get_domain_stats_src_flow
        """
        param = CdnStatsParam(start_time='2019-05-26T00:00:00Z', end_time='2019-05-26T01:00:00Z', key_type=0,
                              key=['opencdn3.sys-qa.com'], period=300, groupBy='')
        param.metric = 'src_flow'
        response = c.get_domain_stats(param)
        print(response)

    命中率相关

    查询字节命中率

    def test_get_domain_stats_real_hit(c):
        """
        test_get_domain_stats_real_hit
        """
        param = CdnStatsParam(start_time='2019-05-26T00:00:00Z', end_time='2019-05-26T01:00:00Z', key_type=0,
                              key=['opencdn3.sys-qa.com'], period=300, groupBy='')
        param.metric = 'real_hit'
        response = c.get_domain_stats(param)
        print(response)

    查询请求命中率

    def test_get_domain_stats_pv_hit(c):
        """
        test_get_domain_stats_pv_hit
        """
        param = CdnStatsParam(start_time='2019-05-26T00:00:00Z', end_time='2019-05-26T01:00:00Z', key_type=0,
                              key=['opencdn3.sys-qa.com'], period=300, groupBy='')
        param.metric = 'pv_hit'
        response = c.get_domain_stats(param)
        print(response)

    状态码相关

    状态码统计查询

    def test_get_domain_stats_httpcode(c):
        """
        test_get_domain_stats_httpcode
        """
        param = CdnStatsParam(start_time='2019-05-26T00:00:00Z', end_time='2019-05-26T01:00:00Z', key_type=0,
                              key=['opencdn3.sys-qa.com'], period=300, groupBy='')
        param.metric = 'httpcode'
        response = c.get_domain_stats(param)
        print(response)

    回源状态码查询

    def test_get_domain_stats_src_httpcode(c):
        """
        test_get_domain_stats_src_httpcode
        """
        param = CdnStatsParam(start_time='2019-05-26T00:00:00Z', end_time='2019-05-26T01:00:00Z', key_type=0,
                              key=['opencdn3.sys-qa.com'], period=300, groupBy='')
        param.metric = 'src_httpcode'
        response = c.get_domain_stats(param)
        print(response)

    分省份运营商的状态码查询

    def test_get_domain_stats_httpcode_region(c):
        """
        test_get_domain_stats_src_httpcode
        """
        param = CdnStatsParam(start_time='2019-05-26T00:00:00Z', end_time='2019-05-26T01:00:00Z', key_type=0,
                              key=['opencdn3.sys-qa.com'], period=300, groupBy='')
        param.metric = 'httpcode_region'
        param.prov = 'beijing'
        param.isp = 'ct'
        response = c.get_domain_stats(param)
        print(response)

    Top N 查询

    Top Urls

    def test_get_domain_stats_top_urls(c):
        """
        test_get_domain_stats_top_urls
        """
        param = CdnStatsParam(start_time='2019-05-26T00:00:00Z', end_time='2019-05-26T01:00:00Z', key_type=0,
                              key=['opencdn3.sys-qa.com'], period=300, groupBy='')
        param.metric = 'top_urls'
        param.extra = 200
        response = c.get_domain_stats(param)
        print(response)

    Top Referers

    def test_get_domain_stats_top_referers(c):
        """
        test_get_domain_stats_top_referers
        """
        param = CdnStatsParam(start_time='2019-05-26T00:00:00Z', end_time='2019-05-26T01:00:00Z', key_type=0,
                              key=['opencdn3.sys-qa.com'], period=300, groupBy='')
        param.metric = 'top_referers'
        param.extra = 200
        response = c.get_domain_stats(param)
        print(response)

    Top Domains

    def test_get_domain_stats_top_domains(c):
        """
        test_get_domain_stats_top_domains
        """
        param = CdnStatsParam(start_time='2019-05-26T00:00:00Z', end_time='2019-05-26T01:00:00Z', period=300, groupBy='')
        param.metric = 'top_domains'
        param.extra = 200
        response = c.get_domain_stats(param)
        print(response)

    错误状态码原因查询

    def test_get_domain_stats_error(c):
        """
        test_get_domain_stats_error
        """
        param = CdnStatsParam(start_time='2019-05-26T00:00:00Z', end_time='2019-05-26T01:00:00Z', key_type=0,
                              key=['opencdn3.sys-qa.com'], period=300, groupBy='')
        param.metric = 'error'
        response = c.get_domain_stats(param)
        print(response)
    上一篇
    动态加速接口
    下一篇
    统计接口(旧版)