[英]nginx log analysis with goaccess
I want to parse and analyze the nginx logs with goaccess and take a report from the analyzed logs. 我想用goaccess解析和分析nginx日志,并从分析的日志中获取报告。 But, when I run the zcat -f access.log.*.gz | goaccess -a -c
但是,当我运行zcat -f access.log.*.gz | goaccess -a -c
zcat -f access.log.*.gz | goaccess -a -c
command, it gives me the following error : 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.
I tried to add the line date_format %D %T
to .goaccessrc file but I got another error which is: 我试图将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.
I think it asks for the date and log formats that nginx uses. 我认为它要求nginx使用的日期和日志格式。 but I have no any date or log format in my nginx configuration. 但我的nginx配置中没有任何日期或日志格式。
Additionally, I've tried to use a previous version of goaccess(0.4.2 version) and the zcat -f access.log.*.gz | goaccess -a -c
另外,我尝试使用以前版本的goaccess(0.4.2版本)和zcat -f access.log.*.gz | goaccess -a -c
zcat -f access.log.*.gz | goaccess -a -c
command works fine. zcat -f access.log.*.gz | goaccess -a -c
命令工作正常。 it doesn't asks for any date or log format and i can view the goaccess menu and i can view any data that want. 它没有要求任何日期或日志格式,我可以查看goaccess菜单,我可以查看任何想要的数据。
But when I try to get a html report with zcat -f access.log.*.gz | goaccess -a -c > report.html
但是当我尝试使用zcat -f access.log.*.gz | goaccess -a -c > report.html
获取html报告时 zcat -f access.log.*.gz | goaccess -a -c > report.html
command, it does nothing. zcat -f access.log.*.gz | goaccess -a -c > report.html
命令,它什么都不做。 it just waits and waits.(without giving any warning or error) 它只是等待和等待。(没有给出任何警告或错误)
Note: i've checked this webpages and if you want to take a look too. 注意:我已经检查了这个网页,如果你想看一看。
Got it working with the following ~/.goaccessrc
: 得到它使用以下~/.goaccessrc
:
date_format %d/%b/%Y:%T %z
log_format %h - - [%d] "%r" %s %b "%R" "%u"
I installed GoAccess as a binary package from wheezy repository (no source recompilation). 我从Goezy存储库中安装了GoAccess作为二进制包(没有源代码重新编译)。
Assuming you are using the CLF format string, I would run goaccess
with -c
and then choose NCSA Combined Log Format
from the config menu. 假设您正在使用CLF格式字符串,我将使用-c
运行goaccess
,然后从配置菜单中选择NCSA Combined Log Format
。
"$time_local"
in nginx is replaced with "23/Aug/2010:03:50:59 +0000"
so adding date_format %d/%b/%Y
to your ~/.goaccessrc should do it. nginx中的"$time_local"
替换为"23/Aug/2010:03:50:59 +0000"
因此将date_format %d/%b/%Y
到〜/ .goaccessrc应该这样做。
Update 1 : 更新1 :
Installing v0.5 from source 从源代码安装v0.5
Download
the latest version Download
最新版本 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
Note: If you have it installed already, then you may only need to do step 7 prior to using zcat
注意:如果已经安装了它,那么在使用zcat
之前,您可能只需要执行第7步
If you don't want to use the global options use --no-global-config
option with goaccess. 如果您不想使用全局选项,请在goaccess中使用--no-global-config
选项。 I am using this to process my log files on a day by day basis: 我正在使用它来处理我的日志文件:
grep --color=auto `date +"%d/%b"` /var/log/nginx/sitename.access.log | goaccess --no-global-config > report.html
goaccess version: 0.8 goaccess版本:0.8
I met the same problem with you! 我遇到了同样的问题! Configuration file path is correct " /etc/goaccess.conf " try to do this 配置文件路径是否正确“/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
and try again,I wish you success 再试一次,祝你成功
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.