NGINX访问中心
云日志服务支持日志采集向导一站式采集NGINX日志,并为NGINX日志配置结构化和仪表盘。该仪表盘主要展示ELB日志的PV对比、访问量PV分布(中国)、访问量PV分布(世界)、访问量UV分布(中国)、访问量UV分布(世界)、平均时延分布(中国)、平均时延分布(世界)、今日PV/UV、7日PV/UV、区域访问TOP10(省份)、区域访问TOP10(城市)、Host访问TOP10、UserAgent访问TOP10、设备占比(终端)、设备占比(系统)、TOP URL、TOP 访问IP等信息,全方位展示网站访问情况。您还可以使用云日志服务的查询分析语句,分析网站的延时情况,及时调优网站。
背景信息
Nginx (engine x) 是一个高性能的HTTP和反向代理web服务器,同时也提供了IMAP/POP3/SMTP服务。
分析网站访问情况
- 登录云日志服务控制台。
- 在左侧导航栏中选择“仪表盘 ”。
- 在仪表盘模板下方,选择“NGINX仪表盘模板>NGINX访问中心”仪表盘,查看图表详情。
NGINX访问中心仪表盘中的重要图表说明如下所示:
- PV对比昨日图展示PV数对比昨日的变化情况,所关联的查询分析语句如下所示:
select diff[1] as "total", round((diff[1] - diff[2]) / diff[2] * 100, 2) as inc from(select compare( "pv" , 86400) as diff from (select count(1) as "pv" from log))
- PV对比上周图展示PV数对比上周的变化情况,所关联的查询分析语句如下所示:
select diff[1] as "total", round((diff[1] - diff[2]) / diff[2] * 100, 2) as inc from(select compare( "pv" , 604800) as diff from (select count(1) as "pv" from log))
- UV对比昨日图展示UV数对比昨日的变化情况,所关联的查询分析语句如下所示:
select diff[1] as "total", round((diff[1] - diff[2]) / diff[2] * 100, 2) as inc from(select compare( "uv" , 86400) as diff from (select APPROX_COUNT_DISTINCT(my_remote_addr) as "uv" from log))
- UV对比上周图展示UV数对比上周的变化情况,所关联的查询分析语句如下所示:
select diff[1] as "total", round((diff[1] - diff[2]) / diff[2] * 100, 2) as inc from(select compare( "uv" , 604800) as diff from (select APPROX_COUNT_DISTINCT(my_remote_addr) as "uv" from log))
- 访问量PV分布(中国)图展示中国区域内访问量PV的分布情况,所关联的查询分析语句如下所示:
select ip_to_province(remote_addr) as province, count(1) as pv where IP_TO_COUNTRY (remote_addr) = '中国' group by province HAVING province not in ('','保留地址','*')
- 访问量PV分布(世界)图展示世界区域内访问量PV的分布情况,所关联的查询分析语句如下所示:
SELECT ip_to_country(remote_addr) as country,COUNT(1) as PV GROUP BY country HAVING country not in ('','保留地址','*')
- 访问量UV分布(中国)图展示中国区域内访问量UV的分布情况,所关联的查询分析语句如下所示:
select ip_to_province(remote_addr) as province, APPROX_COUNT_DISTINCT(remote_addr) as UV where IP_TO_COUNTRY (remote_addr) = '中国' group by province HAVING province not in ('','保留地址','*')
- 访问量UV分布(世界)图展示世界区域内访问量UV的分布情况,所关联的查询分析语句如下所示:
select ip_to_country(remote_addr) as country, APPROX_COUNT_DISTINCT(remote_addr) as uv group by country HAVING country not in ('','保留地址','*')
- 平均时延分布(中国)图展示中国区域内平均时延的分布情况,所关联的查询分析语句如下所示:
SELECT province,round( CASE WHEN "平均延迟(ms)" > 0 THEN "平均延迟(ms)" ELSE 0 END, 3 ) AS "平均延迟(ms)"FROM (SELECT ip_to_province(remote_addr) as province,avg(request_time) * 1000 AS "平均延迟(ms)"WHERE IP_TO_COUNTRY (remote_addr) = '中国'GROUP BY province HAVING province not in ('','保留地址','*'))
- 平均时延分布(世界)图展示世界区域内平均时延的分布情况,所关联的查询分析语句如下所示:
SELECT country,round( CASE WHEN "平均延迟(ms)" > 0 THEN "平均延迟(ms)" ELSE 0 END, 2 ) AS "平均延迟(ms)"FROM (SELECT ip_to_country(remote_addr) as country,avg(request_time) * 1000 AS "平均延迟(ms)" GROUP BY country HAVING country not in ('','保留地址','*'))
- 今日PV/UV图展示最近一天的PV/UV数,所关联的查询分析语句如下所示:
SELECT TIME_FORMAT( _time_, 'yyyy-MM-dd HH:mm:ss', '+08:00' ) as _time_,PV,UV FROM (select TIME_CEIL(__time,'PT600S') AS _time_ , count(1) as PV, APPROX_COUNT_DISTINCT(my_remote_addr) as UV from log WHERE __time <= CURRENT_TIMESTAMP and __time >= DATE_TRUNC( 'DAY',(CURRENT_TIMESTAMP + INTERVAL '8' HOUR)) - INTERVAL '8' HOUR group by _time_ order by _time_) WHERE _time_ <= CURRENT_TIMESTAMP LIMIT 100000 OFFSET 1
- 7日PV/UV图展示七天的PV/UV数,所关联的查询分析语句如下所示:
SELECT TIME_FORMAT( _time_, 'yyyy-MM-dd HH:mm:ss', '+08:00' ) as _time_,PV,UV FROM (select TIME_CEIL(__time,'PT600S') AS _time_ , count(1) as PV, APPROX_COUNT_DISTINCT(remote_addr) as UV from log WHERE __time <= CURRENT_TIMESTAMP and __time >= DATE_TRUNC( 'DAY',(CURRENT_TIMESTAMP + INTERVAL '8' HOUR)) - INTERVAL '8' HOUR - INTERVAL '7' DAY group by _time_ order by _time_ ) WHERE _time_ <= CURRENT_TIMESTAMP LIMIT 100000 OFFSET 1
- 区域访问TOP10(省份)图展示访问排名前十的省份,所关联的查询分析语句如下所示:
select ip_to_province(remote_addr) as "province", count(1) as "访问次数" group by "province" HAVING "province" <> '-1' order by "访问次数" asc limit 10
- 区域访问TOP10(城市)图展示访问排名前十的城市,所关联的查询分析语句如下所示:
select ip_to_city(remote_addr) as "city", count(1) as "访问次数" group by "city" HAVING "city" <> '-1' order by "访问次数" asc limit 10
- Host访问TOP10图展示访问排名前十的主机,所关联的查询分析语句如下所示:
select host as "Host", count(1) as "PV" group by "Host" order by "PV" asc limit 10
- UserAgent访问TOP10图展示访问排名前十的UserAgent,所关联的查询分析语句如下所示:
select http_user_agent as "UserAgent", count(1) as "PV" group by "UserAgent" order by "PV" asc limit 10
- 设备占比(终端)图展示各终端设备的访问占比,所关联的查询分析语句如下所示:
select case when regexp_like(lower(http_user_agent), 'iphone|ipod|android|ios') then '移动端' else 'PC端' end as type , count(1) as total group by type
- 设备占比(系统)图展示各系统设备的访问占比,所关联的查询分析语句如下所示:
select case when regexp_like(lower(http_user_agent), 'iphone|ipod|ios') then 'IOS' when regexp_like(lower(http_user_agent), 'android') then 'Android' else 'other' end as type , count(1) as total group by type HAVING type != 'other'
- TOP URL图展示访问前十url的PV、UV及访问成功率等信息,所关联的查询分析语句如下所示:
select request_uri , count(1) as PV, APPROX_COUNT_DISTINCT(remote_addr) as UV, round(sum( case when status < 400 then 1 else 0 end ) * 100.0 / count(1), 2) as "访问成功率" group by request_uri ORDER by PV desc
- TOP 访问IP图展示访问前十的IP及城市、运营商和PV等数据,所关联的查询分析语句如下所示:
select remote_addr as "来源IP",ip_to_country(remote_addr) as "国家",ip_to_province(remote_addr) as "省份",ip_to_city(remote_addr) as "城市",ip_to_provider(remote_addr) as "运营商",count(1) as "PV",http_user_agent as "UserAgent采样",request_uri as "URL采样" group by remote_addr,http_user_agent,request_uri ORDER by "PV" desc