Using GoAccess web log analyzer with NGINX logs.

By isendev.

 Posted on 2017/08/10 20:36.

 Tagged as: raspberrypi, linux.

This is another quick note that shows how to install GoAccess web log analyzer with NGINX logs on Raspbian / Raspberry Pi.

What's GoAccess? Taken from its site:

GoAccess is an open source real-time web log analyzer and interactive viewer that runs in a terminal in *nix systems or through your browser. It provides fast and valuable HTTP statistics for system administrators that require a visual server report on the fly.

We will assume that an instance of NGINX is already running on your Raspberry Pi.

First of all, install GoAccess. It's avalaible through the Raspbian repositories.

apt-get install goaccess

Now uncomment the following lines from the GoAccess config file /etc/goaccess.conf, using your favourite text editor.

emacs /etc/goaccess.conf]

date-format %d/%b/%Y
log-format %h %^[%d:%^] "%r" %s %b "%R" "%u"

These lines set the default date format to Apache format and the default log format to NCSA Combined Log Format, both used by the NGINX logs. Now, test GoAccess with current NGINX log file:

goaccess -f /var/log/nginx/access.log

And if you want to process all gzipped log archives (this may take a while), use this:

zcat -f /var/log/nginx/access.log* | goaccess

Important: Note that all commands are executed as root. If you do not have access to a root shell (by default you are not allowed to use it), use sudo to execute them (prefix all commands with "sudo").