内容分发网络CDN

    统计与日志接口

    查询域名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);
    }

    注意: 当不指定domainName的时候,查询返回的结果为用户所有加速域名的pv统计之和

    查询域名流量

    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);
    }

    注意: 当不指定domainName的时候,查询返回的结果为用户所有加速域名的流量统计之和

    查询域名状态码统计

    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);
    }

    注意: 当不指定domainName的时候,查询返回的结果为用户所有加速域名的状态码统计之和

    查询域名命中率

    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);
    }

    注意: 当不指定domainName的时候,查询返回的结果为用户所有加速域名的命中率统计之和

    查询过去域名访次数Top 100的url

    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);
    }

    注意: 当不指定domainName的时候,查询返回的结果为用户所有加速域名的统计汇总

    查询过去域名访次数Top 100的referer

    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);
    }

    注意: 当不指定domainName的时候,查询返回的结果为用户所有加速域名的统计汇总

    获取访问日志

    public void testGetLogs(CdnClient client, String domainName) {
        // 查询指定域名过去两个小时的访问日志
        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);
    }

    获取多个域名日志

     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);
        }
    上一篇
    域名配置
    下一篇
    缓存管理