百度智能云

All Product Document

          CDN

          Statistics and Log Interface

          Query Domain Name pv

          public void getDomainPv(CdnClient client, String domainName) throws Exception { 
              SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm"); 
              GetStatPvRequest request = new GetStatPvRequest() 
                      .withDomain(domainName) 
                      .withStartTime(sdf.parse("2017-03-10 10:00")) 
                      .withEndTime(sdf.parse("2017-03-11 10:00")); 
              GetStatPvResponse response = client.getStatPv(request); 
              System.out.println(response); 
          } 

          Note When the domainName is not specified, the result of the query return is the sum of the pv statistics of all the user’s accelerated domain names.

          Query Domain Name Traffic

          public void getDomainFlow(CdnClient client, String domainName) throws Exception { 
              SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm"); 
              GetStatFlowRequest request = new GetStatFlowRequest() 
                      .withDomain(domainName) 
                      .withStartTime(sdf.parse("2017-03-10 10:00")) 
                      .withEndTime(sdf.parse("2017-03-11 10:00")); 
              GetStatFlowResponse response = client.getStatFlow(request); 
              System.out.println(response); 
          } 

          Note When domainName is not specified, return the sum of traffic statistics of all accelerated domain names of the user.

          Query Domain Name Status Code Statistics

          public void getDomainHttpCode(CdnClient client, String domainName) throws Exception { 
              SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm"); 
              GetStatHttpCodeRequest request = new GetStatHttpCodeRequest() 
                      .withDomain(domainName) 
                      .withStartTime(sdf.parse("2017-03-10 10:00")) 
                      .withEndTime(sdf.parse("2017-03-11 10:00")); 
              GetStatHttpCodeResponse response = client.getStatHttpCode(request); 
              System.out.println(response); 
          } 

          Note When domainName is not specified, return the sum of status code statistics of all accelerated domain names of the user.

          Query the Domain Name Hit Rate

          public void getDomainHitRate(CdnClient client, String domainName) throws Exception { 
              SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm"); 
              GetStatHitRateRequest request = new GetStatHitRateRequest() 
                      .withDomain(domainName) 
                      .withStartTime(sdf.parse("2017-03-10 10:00")) 
                      .withEndTime(sdf.parse("2017-03-11 10:00")); 
              GetStatHitRateResponse response = client.getStatHitRate(request); 
              System.out.println(response); 
          } 

          Note When domainName is not specified, return the sum of the hit rate statistics of all accelerated domain names of the user.

          Query the url with Top 100 Domain Name Accesses in the Past

          public void testGetDomainTopUrl(CdnClient client, String domainName) throws Exception { 
              GetStatTopUrlRequest request = new GetStatTopUrlRequest() 
                      .withDomain(domainName) 
                      .withStartTime(new Date(new Date().getTime() - 3600*1000)) 
                      .withEndTime(new Date()) 
                      .withPeriod(3600); 
              GetStatTopUrlResponse response = client.getStatTopUrl(request); 
              System.out.println(response); 
          } 

          Note When domainName is not specified, return the sum of statistics of all accelerated domain names of the user.

          Query the Referer with Top 100 Domain Name Accesses in the Past

          public void testGetDomainTopReferer(CdnClient client, String domainName) throws Exception { 
              GetStatTopRefererRequest request = new GetStatTopRefererRequest() 
                      .withDomain(domainName) 
                      .withStartTime(new Date(new Date().getTime() - 3600*1000)) 
                      .withEndTime(new Date()) 
                      .withPeriod(3600); 
              GetStatTopRefererResponse response = client.getStatTopReferer(request); 
              System.out.println(response); 
          } 

          Note When domainName is not specified, return the sum of statistics of all accelerated domain names of the user.

          Get the Access Logs

          public void testGetLogs(CdnClient client, String domainName) { 
              //Query the access logs of the assigned domain name in the past two hours 
              GetDomainLogRequest request = new GetDomainLogRequest() 
                      .withDomain(domainName) 
                      .withStartTime(new Date(new Date().getTime() - 3600*2000)) 
                      .withEndTime(new Date()); 
              GetDomainLogResponse response = client.getDomainLog(request); 
              System.out.println(response); 
          } 

          Access Multiple Logs of Domain Name

           public void getDomainsLog(){ 
                  GetDomainsLogRequest request=new GetDomainsLogRequest().withType(2L).withStartTime("2020-03-04T00:00:00Z") 
                          .withEndTime("2020-03-04T23:00:00Z").withPageNo(1).withPageSize(1000) 
                          .withDomains(Arrays.asList("vd3.bdstatic.com")); 
                  GetDomainsLogResponse response = cdnClient.getDomainsLog(request); 
                  System.out.println(response); 
              } 
           public void getUploadPeak(){ 
                  GetUploadPeakRequest request=new GetUploadPeakRequest().withStartTime("2020-02-05T00:00:00Z") 
                          .withEndTime("2020-02-06T03:00:00Z").withLevel("internal").withPeriod(3600) 
                          .withDomains(new ArrayList<String>()).withType("95_peak"); 
                  GetUploadPeakResponse response = cdnClient.getUploadPeak(request); 
                  System.out.println(response); 
              } 
          Previous
          Domain Name Configuration
          Next
          Cache Management