首页 文章

使用goaccess进行nginx日志分析

提问于
浏览
21

我想用_213810解析和分析nginx日志,并从分析的日志中获取报告 . 但是,当我运行 zcat -f access.log.*.gz | goaccess -a -c 命令时,它会给我以下错误:

GoAccess - version 0.5 - Jun 26 2012 04:30:08
An error has occurred
Error occured at: parser.c - process_log - 584
Message: No date format was found on your conf file.

我试图将行 date_format %D %T 添加到.goaccessrc文件,但我得到另一个错误,即:

GoAccess - version 0.5 - Jun 26 2012 04:30:08
An error has occurred
Error occured at: parser.c - process_log - 588
Message: No log format was found on your conf file.

我认为它要求nginx使用的日期和日志格式 . 但我的nginx配置中没有任何日期或日志格式 .

另外,我尝试使用以前版本的goaccess(0.4.2版本), zcat -f access.log.*.gz | goaccess -a -c 命令工作正常 . 它没有要求任何日期或日志格式,我可以查看goaccess菜单,我可以查看任何想要的数据 .

但是当我尝试使用 zcat -f access.log.*.gz | goaccess -a -c > report.html 命令获取html报告时,它什么也没做 . 它只是等待和等待 . (没有给出任何警告或错误)

注意:我已经检查了这个网页,如果你想看一看 .

4 回答

  • 25

    假设您正在使用CLF格式字符串,我将使用 -c 运行 goaccess ,然后从配置菜单中选择 NCSA Combined Log Format .

    enter image description here

    nginx中的 "$time_local""23/Aug/2010:03:50:59 +0000" 替换,因此将 date_format %d/%b/%Y 添加到〜/ .goaccessrc应该这样做 .

    Update 1

    从源代码安装v0.5

    • Download latest version

    • tar -xzvf goaccess-0.5.tar.gz

    • cd goaccess-0.5/

    • ./configure --enable-utf8

    • make

    • sudo make install

    • goaccess -a -c /var/log/apache2/access.log

    注意:如果您已经安装了它,那么在使用 zcat 之前您可能只需要执行步骤7

  • 6

    如果您不想使用全局选项,请使用带有goaccess的 --no-global-config 选项 . 我使用它来处理我的日志文件:

    grep --color=auto `date +"%d/%b"` /var/log/nginx/sitename.access.log | goaccess --no-global-config > report.html
    

    goaccess版本:0.8

  • 3

    我遇到了同样的问题!配置文件路径是否正确“/etc/goaccess.conf”尝试这样做

    echo "date_format %d/%b/%Y
    > log_format %h %^[%d:%^] “%r” %s %b “%R” “%u” %T
    > time_format %H:%M:%S" >> /etc/goaccess.conf
    

    再试一次,祝你成功

  • 14

    得到它与以下 ~/.goaccessrc

    date_format %d/%b/%Y:%T %z
    log_format %h - - [%d] "%r" %s %b "%R" "%u"
    

    我从Wheezy存储库中安装了GoAccess作为二进制包(没有源代码重新编译) .

相关问题