百度智能云

All Product Document

          CDN

          Statistical Interface (new version)

          Create the Query Parameter

          CdnStatsParam is the query parameter of statistics related interfaces. You can refer to the following code to create a 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='') 

          Parameter description:

          Parameter Optional Type Description Effective range
          metric Required String Specify the statistical dimension of the query, such as pv, pv_region and flow. -
          end_time Optional String End value of the time range queried, the default is the current time. The time span is 90 days at most ALL
          start_time Optional String Start time of the time range queried, the default is 24 hours ahead of the endTime. ALL
          period Optional Long Granularity of the query, in seconds, you can select 60, 300, 3,600 and 86,400, and the default is 300. uv is 3,600 by default. ALL
          key_type Optional Long Identify the key content, 0=> domain name, 1=>username id, 2=>tag, 0 by default ALL
          key Optional list Domain name or user Id or Tag ALL
          groupBy Optional String Return the aggregate granular of the result, key=> aggregate according to key, null=> return the overall result ALL
          level Optional String All nodes (all), edge (edge) or internal (internal), defaults to all pv、flow
          prov Optional String Full spell of the province queried, and it is empty by default. Query national data. region related
          isp Optional String ISP code to be queried, it is empty by default. Query all operator data. region related
          protocol Optional String Query http or https traffic and bandwidth. The value is {‘http’, ‘https’, ‘all’}, and the default is ‘all’. flow_protocol
          extra Optional Long Query the record of the specified http status code, the default value:"" top n related

          Comments:

          Effective range means that some parameters are effective for all metrics, and some parameters are effective for some metrics. See the test case for details.

          Average Speed

          Query Average Rate

          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) 

          Query the Average Rate of Access Distribution by Client

          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) 

          Query 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) 

          Query pv/qps of Access Distribution by Client

          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) 

          Query Origin 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) 

          Query 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) 

          Query Traffic and Bandwidth

          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) 

          Query Traffic and Bandwidth by Protocol

          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) 

          Query the Traffic Bandwidth of the Internet Service Provider in Different Provinces

          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) 

          Query Origin Traffic and Bandwidth

          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) 

          Query byte Hit Rate

          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) 

          Query Request Hit Rate

          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) 

          Statistical Query of Status Code

          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) 

          Query Origin Status Codes

          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) 

          Query the States Code of Operators by Province

          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 NQuery

          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) 

          Query Reasons of Status Code Error

          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)
          Previous
          Dynamic Acceleration Interface
          Next
          Statistical Interface (old version)