GoAccess¶
GoAccess is an open source realtime web log analyzer and viewer. It use the standard web server log file as source to build a readable graphical HTML output as web page (dashboard) or an overview in the shell.
This documentation describe the way to let create a static web page as overview, which will be updated every hour with a cron job. More details are on the man page and on GitHub available.
License¶
GoAccess is released under the MIT License
Installation¶
GoAccess is already pre-installed on uberspace. This guide describes how to use it effectively.
Configuration¶
After the installation of GoAccess, it is necessary to enable the web server logs and to configure GoAccess with the right log format.
Enable the Web Server Log¶
Please follow the instructions in the uberspace manual to enable the web server logs.
Note
Please consider, after the web server log enabling, it needs some time to have some entries in your new log files. Depends on the web traffic.
GoAccess Configuration¶
Copy the default configuration:
[isabell@stardust ~]$ cp /etc/goaccess/goaccess.conf ~/etc/goaccess.conf
Edit the configuration file and uncomment the following parameters:
# NCSA Combined Log Format with Vitual Host
log-format VCOMBINED
# Set HTML report page title and header.
html-report-title My Uberspace
Launch¶
First Try (or Realtime Analysis in the Shell)¶
To get first results, to check that everything is maintained, please enter:
[isabell@stardust ~]$ goaccess --agent-list --config-file ~/etc/goaccess.conf --log-file <(cat ~/logs/webserver/access_log*)
Scroll with your cursor keys up and down. With “q” you can quit GoAccess.
HTML Output¶
This is the graphical variant as static HTML web page. I consider a new folder inside the html location, that you have access from outside on your statistics.
[isabell@stardust ~]$ mkdir ~/html/statistics
[isabell@stardust ~]$
The command to create a static file with GoAccess is:
[isabell@stardust ~]$ goaccess --agent-list --config-file ~/etc/goaccess.conf --log-file <(cat ~/logs/webserver/access_log*) --output ~/html/statistics/report.html
Warning
The content of ~/html
is publicly accessible. To protect it from unintended visitors, set up HTTP basic authentication using an .htaccess
file.
To view the statistics, point your browser to your uberspace URL, e.g. https://isabell.uber.space/statistics/report.html
.
Script File¶
To create a GoAccess file with a cron job every hour as example, a script is helpful. The location and name for the script file is: ~/bin/goaccess_generate_statistics.sh
#!/bin/bash
goaccess --agent-list --config-file ~/etc/goaccess.conf --log-file <(cat ~/logs/webserver/access_log*) --output ~/html/statistics/report.html
Make your script file executable with:
[isabell@stardust ~]$ chmod +x ~/bin/goaccess_generate_statistics.sh
[isabell@stardust ~]$
Cron Job¶
Cron jobs are described in detail in the Uberspace manual. In this case i consider the following task:
[isabell@stardust ~]$ crontab -e
[isabell@stardust ~]$
and content:
0 * * * * $HOME/bin/goaccess_generate_statistics.sh >/dev/null 2>&1
Best Practices¶
The actual readable web log file is valid for one week. With other words, a long term statistics is not possible.
Tested with Uberspace 7.11.1.1 and GoAccess 1.3
Written by: FM <git.fm@mmw9.de>Frederik Niedernolte <peleke7@uber.space>