Grafana展示Web访问日志分析及查询语句

 

Grafana展示Web访问日志分析及查询语句_第1张图片

Grafana展示Web访问日志分析及查询语句_第2张图片

Grafana展示Web访问日志分析及查询语句_第3张图片

$hostname 和 $$myinterval  环境变量设置如下图:

Grafana展示Web访问日志分析及查询语句_第4张图片

通过阿里云日志服务API接口查询语句。 

1、查询系统全后端请求延迟   
$hostname | select avg(request_time) as response_time, avg(upstream_response_time) as    upstream_response_time ,__time__ - __time__ % $$myinterval as time group by __time__ -               __time__ % $$myinterval limit 10000

Y轴:upstream_response_time,response_time  X轴:time  

2、出入带宽
$hostname | select sum(body_bytes_sent) as net_out,sum(request_length) as net_in,__time__ - __time__ % $$myinterval as time group by __time__ - __time__ % $$myinterval limit 10000
Y轴:net_out,net_in   X轴:time

3、PV/UV统计
$hostname | select approx_distinct(remote_addr) as uv ,count(1) as pv , __time__-__time__ % $$myinterval as time group by time order by time limit 1000
Y轴:pv,uv            X轴:time

4、请求客户端统计
*  | select count(1) as pv, case when  regexp_like(http_user_agent , 'okhttp') then 'okhttp' when  regexp_like(http_user_agent ,  'iPhone') then 'iPhone' when regexp_like(http_user_agent ,  'Android')  then 'Android' when regexp_like (http_user_agent, 'CFNetwork') then 'IOS'  when regexp_like (http_user_agent, 'Windows') then 'Windows'  when regexp_like (http_user_agent, 'Apache') then 'Apache_http_client'  else 'unKnown' end as http_user_agent group by  http_user_agent order by pv desc limit 10
Y轴:http_user_agent,pv  X轴:pie

5、请求方法统计
$hostname | select count(1) as pv,request_method group by request_method
Y轴:request_method,pv  X轴:pie

6、HTTP状态统计
$hostname | select count(1) as pv ,status group by status
Y轴:status,pv  X轴:pie

7、访问前10地址
$hostname  | select count(1) as pv, split_part(request_uri,'?',1) as path group by split_part(request_uri,'?',1) order by pv desc limit 20
Y轴:path,pv   X轴: 空值
8、热门访问来源
$hostname | select count(1) as pv , http_referer group by http_referer order by pv desc
Y轴 http_referer,pv  X轴 pie
9、非200状态请求
$hostname not status: 200 | select count(1) as pv ,request_uri group by request_uri order by pv desc
Y轴:request_uri,pv   X轴: 空值
10、请求耗时前十地址
*| select request_uri as top_latency_url ,request_time order by request_time desc limit 10
Y轴:top_latency_url,request_time  X值: 空值

 

你可能感兴趣的:(学习)