Analyzing Web Logs with GoAccess

GoAccess Live Demo

Occasionally I wonder if anyone actually visits this site. So several years ago I went to find something that would help me watch my web logs.

The solution I found was GoAccess. It is an interactive program that behaves like top when you run it in a terminal against your /var/log/nginx or /var/log/httpd directories.

GoAccess is packaged in every major OS:

It can also statically create a report:

1
2
3
4
5
6
7
8
9
10
11
#!/bin/bash

mkdir /tmp/report
cat /var/log/nginx/access.log > /tmp/report/access.log
zcat /var/log/nginx/access.log.*gz >> /tmp/report/access.log

goaccess /tmp/report/access.log --log-format=COMBINED --ignore-crawlers --real-os --geoip-database /var/www/GeoLite2-City.mmdb -o /var/www/index.html

rm -rf /tmp/report

exit 0

I put the above simple script into Cron:

1
15 6 * * * /home/www-data/report.sh &>/dev/null

And yes, there are occasionally one or two folks who visit.