使用GoAccess对nginx日志的在线监控

Posted cnsu-cmh

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了使用GoAccess对nginx日志的在线监控相关的知识,希望对你有一定的参考价值。

有人用centos,有人用ubuntu,centos文章很多,此文针对ubuntu
 

安装依赖库GeoIP

wget https://github.com/maxmind/geoip-api-c/releases/download/v1.6.11/GeoIP-1.6.11.tar.gz
tar -xzvf GeoIP-1.6.11.tar.gz

cd GeoIP-1.6.11/

./configure

make

make install

 使用--enable-utf8,需要安装ncursesw
sudo apt-get install libncursesw5-dev

安装GoAccess

 wget https://tar.goaccess.io/goaccess-1.4.tar.gz
 tar -xzvf goaccess-1.4.tar.gz
 cd goaccess-1.4/
 ./configure --enable-utf8 --enable-geoip=legacy
 make
 make install

步骤拆分
1.ubuntu安装GoAccess

GoAccess下载地址:GoAccess - Downloads
ubuntu 不支持yum wget先下载解压GoAccess 

 wget https://tar.goaccess.io/goaccess-1.4.tar.gz

 tar -xzvf goaccess-1.4.tar.gz

进入到目录

cd goaccess-1.4/

安装过程会报错  你可先解决错误后再安装 避免错误出现
安装

 ./configure --enable-utf8 --enable-geoip=legacy
 make
 make install

安装过程会出现一下两个错误:
错误1:
configure: error: 
*** Missing development files for the GeoIP library

解决办法 安装依赖GeoIP
下载解压
可以到github下载 https://developer.aliyun.com/packageSearch?word=GeoIPTags · maxmind/geoip-api-c · GitHubhttps://developer.aliyun.com/packageSearch?word=GeoIP

 wget https://github.com/maxmind/geoip-api-c/releases/download/v1.6.11/GeoIP-1.6.11.tar.gz
 tar -xzvf GeoIP-1.6.11.tar.gz

cd进入 GeoIP

 cd GeoIP-1.6.11/

安装依赖库GeoIP

 ./configure
 make
 make install

错误二:
configure: error:
*** Missing development libraries for ncursesw

解决办法 使用--enable-utf8,需要安装ncursesw

安装ncursesw
使用命令apt-get安装

sudo apt-get install libncursesw5-dev

安装步骤拆分结束

GoAccess安装完成后
进入到ngin日志文件logs

cd /usr/local/nginx/logs/

 

  • 启动goaccess,对goaccess.log 进行监控

    goaccess access.log -c

    选择第一项 回车空格    回车进入日志分析
     

  • 对日志进行分析

     

  • 日志生成html

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

    日志分析完成后浏览器访问页面
    本地nginx80端口映射了html路径  所以直接访问http://ip/report.html

     

以上是关于使用GoAccess对nginx日志的在线监控的主要内容,如果未能解决你的问题,请参考以下文章

使用GoAccess对nginx日志的在线监控

重识Nginx - 10 ngx_http_log_module日志模块 & GoAccess日志分析

linux系统centOS6.5使用goaccess工具分析nginx网站日志

lamp架构goaccess日志可视化

lamp架构goaccess日志可视化

lamp架构goaccess日志可视化