Alexander Zeitler

Parsing nginx logs with GoAccess and creating a HTML report in a cron job

Published on Thursday, November 2, 2023

Server logs

Photo by Luke Chesser on Unsplash

Gyula recently asked for a decent cookieless analytics tool on Twitter:

I suggested to use GoAccess to parse the nginx logs and create a HTML report and Hannes asked for a quickstart - so here we go.

Considering we're a running a Linux server with nginx and Docker, here's how to get started and our blog is static HTML generated with 11ty it is as easy as this to have a cron job running every day at 22:05 to create a HTML report of the nginx logs:

5 22 * * * cat /var/opt/deploy/logs/nginx/access.log | /usr/bin/docker run --rm -i -e LANG=$LANG allinurl/goaccess -a -o html --log-format COMBINED - > /var/opt/deploy/www/_site/report.html

The command in detail:

5 22 * * * - run the command every day at 22:05

cat /var/opt/deploy/logs/nginx/access.log - read the nginx access log

| - pipe the output to the next command

/usr/bin/docker run --rm -i -e LANG=$LANG allinurl/goaccess -a -o html --log-format COMBINED - - run the docker container with the GoAccess image and parse the nginx access log and create a HTML report

> /var/opt/deploy/www/_site/report.html - write the HTML report to the file system

The report:

the report

What are your thoughts about
"Parsing nginx logs with GoAccess and creating a HTML report in a cron job"?
Drop me a line - I'm looking forward to your feedback!
Please be aware that I'm no longer active on social media. I'm just cross posting things over there (it's a bot).
Imprint | Privacy