GoAccess - Apache2 Log Analyzer

GoAccess - Apache2 Log Analyzer

I use GoAccess to generate reports for my web server. Following are the steps to get it running:

  1. Per GoAccess installation instructions:

    $ wget https://tar.goaccess.io/goaccess-1.9.3.tar.gz
    $ tar -xzvf goaccess-1.9.3.tar.gz
    $ cd goaccess-1.9.3/
    $ ./configure --enable-utf8 --enable-geoip=mmdb
    $ make
    $ make install
    
  2. Download latest GeoIP2 database from MaxMind. You need a free account with MaxMind. The download contains 3 databases:

    • GeoLite2-City.mmdb
    • GeoLite2-Country.mmdb1
    • GeoLite2-ASN.mmdb

    Place downloaded files in /usr/local/share/GeoIP/.2

  1. Edit GoAccess configuration file /usr/local/etc/goaccess/goaccess.conf. Make sure these lines are uncommented:

    log-format COMBINED
    enable-panel GEO_LOCATION
    

    Add the following lines:

    geoip-database /usr/local/share/GeoIP/GeoLite2-City.mmdb
    geoip-database /usr/local/share/GeoIP/GeoLite2-ASN.mmdb
    
  2. Edit crontab (sudo crontab -e) to add:

    0 1 * * * (cd /var/log/apache2 && zcat access.log.*.gz | goaccess access.log access.log.1 - -o report.html)
    

    Translation: every day at 01:00 pipe all compressed logs (zcat) and uncompressed ones through goaccess and generate report.html output file.


  1. Not sure if it’s needed ↩︎

  2. Other places might work equally well. This one works for me. ↩︎