阿里云SLS可视化编码
-
开启索引:
a. 日志切分
正则网址:https://regex101.com/
b. 开启索引 -
编写图的SQL:
编写完后可以直接新建仪表盘或者添加到现有仪表盘中
-
各种图SQL脚本及展示:
a. 日周环比图:统计图表-线图
* |
SELECT
t,
d [1] as current,
d [2] as yestoday,
d [3] as lastWeek
from(
select
t,
ts_compare(pv, 86400, 604800) as d
from(
select
date_trunc('minute', __time__) as t,
count(1) as pv
FROM log
group by
t
order by
t
)
group by
t
having
t is not null
)
统计图表配置:
展示效果:
b. top10 图:表格
username: * |
select
username,
date_format(from_unixtime(__time__), '%Y-%m-%d') as date,
count(1) as count
FROM log
group by
username,
date
order by
count desc,
date
LIMIT
10
展示效果:
c. 接入日志量统计:柱状图
*|select date_format(from_unixtime(__time__), '%Y-%m-%d') as t,count(1) as count from log group by t order by t
展示效果:
d. 事件分布饼图:饼图
event_type: * |
select
event_type,
count(1) as count
FROM log
group by
event_type
展示效果:
e. 按天按类型统计:流图
appname: * |
select
appname,
date_format(from_unixtime(__time__), '%Y-%m-%d') as t,
count(1) as count
FROM log
group by
appname,
t
order by
t
展示效果:堆叠图