Updated on 2024-11-18 GMT+08:00

CDN Dashboard Templates

CDN logs the requests to all domain names including those deleted. You can ingest these logs to LTS to analyze the access to your service resources in detail. If you have enabled the enterprise project function, log management is not available for deleted domain names.

CDN dashboard templates support Viewing CDN Error Analysis, Viewing CDN Basic Data, Viewing CDN User Analysis, and Viewing Popular CDN Resources.

Prerequisites

Viewing CDN Error Analysis

  1. Log in to the LTS console. In the navigation pane, choose Dashboards.
  2. Choose CDN dashboard templates under Dashboard Templates and click CDN Error Analysis to view the chart details.

    • Top 5 Domain Name Errors. The associated query and analysis statement is:
      select domain , count(*) as c where http_code > 400 group by domain order by c desc limit 5
    • Top 5 URI Errors. The associated query and analysis statement is:
      select uri , count(*) as c where http_code > 400 group by uri order by c desc limit 5
    • Status Codes. The associated query and analysis statement is:
      select http_code , count(*) as c where http_code > 400 group by http_code order by c desc
    • Errors by Carrier. The associated query and analysis statement is:
      select ip_to_provider(client_ip) as isp , count(*) as c where http_code > 400 group by isp having ip_to_provider(client_ip) != '' order by c desc limit 10
    • Errors by Client. The associated query and analysis statement is:
      select user_agent as "Client version", count(*) as "Errors" where http_code > 400 group by user_agent order by "Errors" desc limit 10
    • Errors by Province. The associated query and analysis statement is:
      select ip_to_province(client_ip) as province , count(*) as c where http_code > 400 and  IP_TO_COUNTRY (client_ip) = 'China' group by province order by c desc limit 50
    • 4XX Errors. The associated query and analysis statement is:
      SELECT
            province AS "Province",
            isp AS "Carrier",
            c AS "Errors",
            round( c * 100.0 / sum( c ), 2 ) AS "Rate (%)" 
           FROM
            (
            SELECT
             ip_to_province ( client_ip ) AS province,
             ip_to_provider ( client_ip ) AS isp,
             count(*) AS c 
            FROM
             log 
            WHERE
             http_code >= 400 
             AND http_code < 500 
            GROUP BY
             province,
             isp 
            HAVING
             (
             ip_to_provider ( client_ip )) != '' 
            ORDER BY
             c DESC 
            ) 
           GROUP BY
            province,
            isp,
            c
    • 5XX Errors. The associated query and analysis statement is:
      SELECT
            province AS "Province",
            isp AS "Carrier",
            c AS "Errors",
            round( c * 100.0 / sum( c ), 2 ) AS "Rate (%)" 
           FROM
            (
            SELECT
             ip_to_province ( client_ip ) AS province,
             ip_to_provider ( client_ip ) AS isp,
             count(*) AS c 
            FROM
             log 
            WHERE
                 http_code >= 500
            GROUP BY
             province,
             isp 
            HAVING
             (
             ip_to_provider ( client_ip )) != '' 
            ORDER BY
             c DESC 
            ) 
           GROUP BY
            province,
            isp,
            c
    • Errors by Country. The associated query and analysis statement is:
      select ip_to_country(client_ip) as country , count(*) as c where http_code > 400  group by country order by c desc limit 50

Viewing CDN Basic Data

  1. Log in to the LTS console. In the navigation pane, choose Dashboards.
  2. Choose CDN dashboard templates under Dashboard Templates and click CDN Basic Data to view the chart details.

    • Cache Hit Ratio. The associated query and analysis statement is:
      select round(diff[1],2) as Hit_ratio, round(diff[2],2) as diff, round((diff[3]-1)*100, 2) from (select compare(Hit_ratio, 86400) as diff from (select sum(s) * 100.0/count(*) as Hit_ratio from (select case when hit_info = 'HIT' then 1 else 0 end as s from log)))
    • Download Speed. The associated query and analysis statement is:
      select round(diff[1],2) as speed, round(diff[2],2) as diff, round((diff[3]-1)*100, 2) from (select compare(speed, 86400) as diff from (select sum(response_size) * 1.0 /sum(response_time) as speed from log ))
    • Status Codes. The associated query and analysis statement is:
      select http_code , count(*) as c group by http_code order by c desc
    • Latency Distribution. The associated query and analysis statement is:
      select 
            case when response_time < 100 then '~100ms' 
            when response_time < 500 then '100~500ms' 
            when response_time < 1000 then '500ms~1s' 
            when response_time < 5000 then '1~5s' 
            when response_time < 6000 then '5~6s' 
            when response_time < 7000 then '6~7s' 
            when response_time < 8000 then '7~8s'
            when response_time < 10000 then '8~10s'
            when response_time < 15000 then '10~15s' 
            else '15s~' end as latency , 
            count(*) as cnt 
            group by latency 
            order by  cnt  
    • Request Bandwidth. The associated query and analysis statement is:
      select TIME_FORMAT (TIME_FLOOR(__time,'PT1M'), 'HH:mm', '+08:00') as thisdate, 
            sum(response_size) * 8/1000000000.0 as "Bandwidth (Gbit/min)" 
            group by TIME_FLOOR(__time,'PT1M') 
            order by TIME_FLOOR(__time,'PT1M')
    • Visits and Users. The associated query and analysis statement is:
      select TIME_FORMAT (TIME_FLOOR(__time,'PT1M'), 'HH:mm', '+08:00') as thisdate, 
            count(*) as pv, APPROX_COUNT_DISTINCT(client_ip) as uv group by TIME_FLOOR(__time,'PT1M') order by TIME_FLOOR(__time,'PT1M')
    • Average Latency. The associated query and analysis statement is:
      select TIME_FORMAT (TIME_FLOOR(__time,'PT1M'), 'HH:mm', '+08:00') as thisdate, 
            avg(response_time) as "Average Latency (ms)" group by TIME_FLOOR(__time,'PT1M') order by TIME_FLOOR(__time,'PT1M')
    • Request Hit Ratio. The associated query and analysis statement is:
      select 
            TIME_FORMAT (TIME_FLOOR(m_time,'PT1M'), 'HH:mm', '+08:00' ) as thisdate , 
            sum(is_hit)*100.0/count(*) as hit_ratio 
            from  (select  TIME_FLOOR(__time,'PT1M') as m_time ,  case when hit_info = 'HIT' 
             then 1 else 0 end as is_hit from log ) group by m_time order by m_time

Viewing CDN User Analysis

  1. Log in to the LTS console. In the navigation pane, choose Dashboards.
  2. Choose CDN dashboard templates under Dashboard Templates and click CDN User Analysis to view the chart details.

    • Visits. The associated query and analysis statement is:
      select diff[1] as pv,diff[2] as diff, round(100*(diff[3]-1), 2) from (select compare(pv, 86400) as diff from (select count(*) as pv from log))
    • Visitors. The associated query and analysis statement is:
      select diff[1] as uv, diff[2] as diff, round((diff[3]-1)*100, 2) from (select compare(uv , 86400) as diff from (select APPROX_COUNT_DISTINCT(client_ip) as uv from log))
    • Visits by Client. The associated query and analysis statement is:
      select ua as "Client" , sum(c) as "Visits" from (select case when strpos(ua , 'iphone') > 1 then 'iphone' when strpos(ua, 'ipad') > 1 then 'ipad' when strpos(ua, 'android') > 1 then 'android' when strpos(ua, 'windows') > 1 then 'windows' when strpos(ua , 'mac') > 1 then 'mac' when strpos(ua, 'linux') > 1 then 'linux' else ua end as ua , c from (select count(*) as c , lower(user_agent) as ua from log group by ua order by c desc limit 2000) ) group by "Client" order by "Visits" desc limit 100
    • Visits by Carrier. The associated query and analysis statement is:
      select ip_to_provider(client_ip) as isp ,count(*) as "Visits" group by isp order by "Visits" desc limit 100
    • Visits by Geography. The associated query and analysis statement is:
      select ip_to_province(client_ip) as province , count(*) as cnt where IP_TO_COUNTRY (client_ip) = 'China' group by province HAVING province not in ('','Reserved address','*') order by cnt desc limit 100
    • Top Valid Visitors. The associated query and analysis statement is:
      SELECT  CASE    WHEN ip_to_country(client_ip) = 'Shanghai' THEN concat(client_ip, ' ( shanghai )')    WHEN ip_to_province(client_ip) = '' THEN concat(client_ip, ' ( Unknown IP )')    WHEN ip_to_provider(client_ip) = 'Private IP' THEN concat(client_ip, ' ( Private IP )')    ELSE concat(      client_ip,      ' ( ',      ip_to_country(client_ip),      '/',      ip_to_province(client_ip),      '/',      CASE        WHEN ip_to_city(client_ip) = '-1' THEN 'Unknown city'        ELSE ip_to_city(client_ip)      END,      ' ',      ip_to_provider(client_ip),      ' )'    )  END AS client,  pv as "Total Visits",  (pv - success_count) as "Errors",  round( CASE WHEN "throughput" > 0 THEN "throughput" ELSE 0 END, 1 ) AS "Total Downloads (GB)"from  (    select      client_ip,      count(*) as pv,      sum(response_size) / 1024.0 / 1024 / 1024.0 AS throughput,      sum(        CASE          WHEN http_code < 400 THEN 1          ELSE 0        END      ) AS success_count     from      log     group by      client_ip     order by      success_count desc    limit      100  )
    • Top Visitors by Downloads. The associated query and analysis statement is:
      SELECT CASE WHEN ip_to_country(client_ip)='Shanghai' THEN concat(client_ip, ' ( shanghai )') WHEN ip_to_province(client_ip)='' THEN concat(client_ip, ' ( Unknown IP )') WHEN ip_to_provider(client_ip)='Private IP' THEN concat(client_ip, ' ( Private IP )') ELSE concat(client_ip, ' ( ', ip_to_country(client_ip), '/', ip_to_province(client_ip), '/',        CASE WHEN ip_to_city(client_ip)='-1' THEN 'Unknown city' ELSE ip_to_city(client_ip) END, ' ',ip_to_provider(client_ip), ' )') END AS client,        pv as "Total Visits",        error_count as "Errors" ,      round( CASE WHEN "throughput" > 0 THEN "throughput" ELSE 0 END, 1 ) AS "Total Downloads (GB)"      from (      select client_ip ,        count(*) as pv,        sum(response_size)/1024.0/1024/1024.0 AS throughput ,        sum(CASE WHEN http_code > 400 THEN 1 ELSE 0 END) AS error_count        from log        group by client_ip       order by throughput desc        limit 100)

Viewing Popular CDN Resources

  1. Log in to the LTS console. In the navigation pane, choose Dashboards.
  2. Choose CDN dashboard templates under Dashboard Templates and click Popular CDN Resources to view the chart details.

    • 5 Most Visited Domain Names. The associated query and analysis statement is:
      select domain ,count(*) as cnt group by domain order by cnt desc limit 5
    • 5 Most Downloaded Domain Names. The associated query and analysis statement is:
      select domain , sum(response_size) as "Total Downloads" group by domain order by "Total Downloads" desc limit 5
    • Popular Visits (URI). The associated query and analysis statement is:
      select uri as URI, "Visits", "Visitors", round( CASE WHEN "Total Downloads (GB)" > 0 THEN "Total Downloads (GB)" ELSE 0 END, 2 ) AS "Total Downloads (GB)" from (        select uri ,count(*) as "Visits" , APPROX_COUNT_DISTINCT(client_ip) as "Visitors", sum(response_size)/1024.0/1024.0/1024.0 as "Total Downloads (GB)" where http_code < 400 group by uri order by "Visits" desc limit 100)
    • Popular Visits (Source). The associated query and analysis statement is:
      select refer_domain as "Referer",c as "Times",uv as "Users", round(c * 100.0 / sum(c), 2) as  "Percentage"  from (select refer_domain as refer_domain,count(*) as c,APPROX_COUNT_DISTINCT(client_ip) as uv from log where refer_domain != '' group by refer_domain order by c desc limit 100 ) GROUP BY refer_domain, c, uv
    • Visits by Geography. The associated query and analysis statement is:
      select ip_to_province(client_ip) as province , count(*) as cnt where IP_TO_COUNTRY (client_ip) = 'China' group by province HAVING province not in ('','Reserved address','*') order by cnt desc limit 1000
    • Download Speed by Geography. The associated query and analysis statement is:
      select province, round( CASE WHEN "speed" > 0 THEN "speed" ELSE 0 END, 3 ) AS "speed" from (select ip_to_province(client_ip) as province , sum(response_size)* 1.0 /(sum(response_time)+1) as "speed" , count(*) as c where IP_TO_COUNTRY (client_ip) = 'China' group by province HAVING province not in ('','Reserved address','*') order by c desc limit 40)
    • Statistics by Province. The associated query and analysis statement is:
      select ip_to_province(client_ip) as "Province" ,count(*) as "Visits", sum(response_size)/1024.0/1024.0/1024.0 as "Total Downloads (GB)" , sum(response_size) * 1.0 /sum(response_time) as "Download Speed (KB/s)" group by "Province" having ip_to_province(client_ip) != '' order by "Total Downloads (GB)" desc limit 200
    • Carrier Traffic and Speed. The associated query and analysis statement is:
      select ip_to_provider(client_ip) as isp , sum(response_size)* 1.0 /(sum(response_time)+1) as "Download Speed (KB/s)" , sum(response_size)/1024.0/1024.0/1024.0 as "Total Downloads (GB)", count(*) as c group by isp having ip_to_provider(client_ip) != '' order by c desc limit 10
    • Statistics by Carrier. The associated query and analysis statement is:
      select "Carrier", "Visits", round( CASE WHEN "Total Downloads (GB)" > 0 THEN "Total Downloads (GB)" ELSE 0 END, 2 ) AS "Total Downloads (GB)",        round( CASE WHEN "Download Speed (KB/s)" > 0 THEN "Download Speed (KB/s)" ELSE 0 END, 2 ) AS "Download Speed (KB/s)" from (      select ip_to_provider(client_ip) as "Carrier" ,count(*) as "Visits", sum(response_size)/1024.0/1024.0/1024.0 as "Total Downloads (GB)" , sum(response_size) * 1.0 /sum(response_time) as "Download Speed (KB/s)" group by "Carrier" having ip_to_provider(client_ip) != '' and "Carrier" not in ('*') order by "Total Downloads (GB)" desc limit 200)