I'm looking for a simple tool to analyze my NGINX logs on my macbook. I want to be able to get some basic stats including bot access and also be able to sort/filter the logs to find out what happened right before the server crashed.
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
You may try with GoAccess; free and open source console based. It may output an HTML report too.
回答2:
I've come across visitors. It's written in C and is pretty fast.
It lacks goaccess' cool ncruses interface. It only outputs html. It does the job, though.
Edit: It can also output human-readable text reports:
visitors access.log | less
回答3:
I will suggest to use logstash and Kibana with following patterns :
for access.log :
NGINXACCESS %{IPORHOST:clientip} - %{USERNAME:remote_user} \[%{HTTPDATE:time_local}\] %{QS:request} %{INT:status} %{INT:body_bytes_sent} %{QS:http_referer} %{QS:http_user_agent}
for error.log:
NGINXERROR (?<timestamp>%{YEAR}[./-]%{MONTHNUM}[./-]%{MONTHDAY}[- ]%{TIME}) \[%{LOGLEVEL:severity}\] %{POSINT:pid}#%{NUMBER}: %{GREEDYDATA:errormessage}(?:, client: (?<clientip>%{IP}|%{HOSTNAME}))(?:, server: %{IPORHOST:server})(?:, request: %{QS:request})?(?:, host: %{QS:host})?(?:, referrer: \"%{URI:referrer})?
回答4:
The request-log-analyzer gem now has Nginx support in the master branch and i'm looking for someone to test it. http://github.com/wvanbergen/request-log-analyzer.
回答5:
I've now tried Splunk, it's a pretty powerful tool and they have a free version as well.