Chotaire Wiki

Stuff you didn't know

User Tools

Site Tools


linux-goaccess-nginx

How to create a goaccess static report from nginx with logrotate

Nginx on Debian and Ubuntu makes use of logrotate to keep access logs small. Logs are rotated daily, and everything that's older than 2 days gets gzip-compressed. To create a total report of all accesses to a nginx webserver, follow this tutorial.

Install goaccess

This should work with Debian and Ubuntu:

apt install goaccess

Create static report

This example creates a GDPR compliant report that ignores crawlers and outputs everything into one report.html file. We don't resolve hostnames and do not query GeoIP databases. Depending on the number of accesses recorded, this may still take hours.

cd /var/log/nginx
zcat -f access.log* | goaccess --log-format=COMBINED --anonymize-ip --ignore-crawlers --real-os - -o report.html

The status will show how many log lines have already been processed. To get an idea about how long this would probably take in total, you can count the existing loglines in a second terminal. This will go real quick:

cd /var/log/nginx
zcat -f access.log* | wc -l

To view report.html, you can either move it into a reachable html directory or download it to your PC and open it directly in your browser.



linux-goaccess-nginx.txt ยท Last modified: 2021/05/06 12:37 by chotaire