四时宝库

程序员的知识宝库

领导:如何使用GoAccess构建实时日志分析系统

概述

从goaccess的官网我们可以看到有提供生成html页面的功能,今天就在这个基础上演示下怎么做一个实时的日志分析。


1、 修改配置

1.1、查看当前配置

#egrep -v "^#|^$" /usr/local/etc/goaccess/goaccess.conf

由上可见默认配置中并无时间参数,需要在配置中添加时间参数。

1.2、添加时间参数

# cat >>goaccess.conf<<EOF
time-format %H:%M:%S
date-format %d/%b/%Y
#NCSA Combined Log Format
log-format %h %^[%d:%t %^] "%r" %s %b "%R" "%u"
EOF
#cp -a goaccess.conf ../

2、添加定时任务

30 * * * * goaccess /var/log/nginx/access.log -o /etc/nginx/html/report.html --real-time-html --time-format='%H:%M:%S' --date-format='%d/%b/%Y' --log-format=COMBINED 

3、nginx配置

修改nginx.conf文件

location /report.html {
 #指定个人配置的目录
 root html;
 index report.html index.htm;
 }

4、检查生产页面

https://服务器IP/report.html

页面展示如下:


觉得有用的朋友多帮忙转发哦!后面会分享更多devops和DBA方面的内容,感兴趣的朋友可以关注下~

发表评论:

控制面板
您好,欢迎到访网站!
  查看权限
网站分类
最新留言
    友情链接