Web statistics - GoAccess
Tue, Jan 8, 2019 · 2 minute readlinux
GoAccess
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.
Install
Use apt (or other appropriate package manager) to install packaged version.
As of Jan-2019 package seems to be a long way behind current stable version (at least on Ubuntu), 0.9.4 package compared to 1.3 stable.
In addition, packaged version (at least on Debian/Ubuntu) does not include options, e.g. disk storage.
For more up to date version and to enable optional components, download and compile source.
Install dependencies:
# for --enable-utf8
# apt install libncursesw5-dev
# for disk storage --enable-tcb
# apt install libtokyocabinet-dev
# for BZIP support
# apt install libbz2-dev
Configure and make.
Can use –prefix to override default install location
# ./configure --enable-utf8 --enable-tcb=btree
...
# make
...
# make install
...
# whereis goaccess
goaccess: /usr/local/bin/goaccess /usr/local/etc/goaccess
Edit goaccess.conf
If you have compiled from source and not set the prefix then configuration file will be: /usr/local/etc/goaccess/goaccess.conf
For package installs the configuration file is: /etc/goaccess.conf
The default file is heavily commented.
There are only a few options to change:
time-format %H:%M:%S
# UK based date format for me
date-format %d/%b/%Y
# Access log file format - this described the Apache combined format
log-format %h %^[%d:%t %^] "%r" %s %b "%R" "%u"
Run
$ /usr/local/bin/goaccess \
--config-file=/usr/local/etc/goaccess/goaccess.conf \
-f /www/logs/access.log --html-report-title="test-domain.co.uk" > /www/html/goaccess.html
Monthly stat’s
alan@pib:/www/logs $ dom="test-domain.co.uk"
alan@pib:/www/logs $ mkdir -p ${dom}/2018/11
alan@pib:/www/logs $ grep -r "\[../Nov/2018" /www/logs/${dom}-access.log > ${dom}/2018/11/access.log
alan@pib:/www/logs $ /usr/local/bin/goaccess \
--config-file=/usr/local/etc/goaccess/goaccess.conf \
-f /www/logs/${dom}/2018/11/access.log \
--html-report-title="${dom} Nov-2018" > /www/html/${dom}/2018/11/index.html
It is a simple thing to take that code and wrap it into a script that runs daily to update stat’s for your domain.