Fast and real-time AWStats alternative: GoAccess

Posted

Piwik, Google Analytics or StatCounter are great tools to analyze the traffic of you website and they’re very powerful and customizable. But they’re on client side and it’s complicated to track for example your new COBOL-driven REST API or the number of downloads of a PDF on your server. AWStats was my favorite tool in the past to analyze those server web log files. But it’s written in Perl and the design looks like from the age of COBOL. Now it’s time for a new cool and fancy tool – with real time stats in the terminal and your browser, dashboard, export tools and responsive design to check the success of your web tools on the go: GoAccess

Installation

It’s very easy to install GoAccess on your Gentoo machine. Simply type

# emerge -a net-analyzer/goaccess

And that’s it. Enable geoip to track visits by continent. For a minimal setup there’s only one required dependency ncurses so it’s very easy to compile it from source if you want.

Quick start

Installation done, don’t talk around, lets see something. Check where your log files are – I’m using nginx and I’m using the NCSA Combined Log Format. To get started, type:

goaccess -f /var/log/nginx/mylogfile_access.log

and you’ll get the log format configuration screen. Select your log format (mine is NCSA Combined Log Format) and press [Enter]

Now you can see some wonderful stats in your terminal. And they’re in real time. Access the website you’re monitoring and check the changes in your terminal.

Settings

The configuration file of GoAccess is located in /etc/goaccess.conf by default. You can adjust the settings to skip the log file settings dialog for example. Open the file and set the following lines (you can uncomment the existing entries)

time-format %H:%M:%S
date-format %d/%b/%Y
log-format %h %^[%d:%t %^] "%r" %s %b

Static HTML Export

To export a static HTML page with all the stats, type:

goaccess -f /var/log/nginx/logfile_access.log -o /var/www/localhost/stats/index.html

The index.html contains all the data, JS and a nice look (responsive design). Open your browser and check the details.

RealTime HTML export

With GoAccess you can generate a real time web view as well (like the ncurses-one on the command line). This will generate the static HTML file and will establish a WebSocket connection to your host when calling this index.html file. To generate the file and allow real time connection, type:

goaccess -f /var/log/nginx/logfile_access.log -o /var/www/localhost/stats/index.html --real-time-html

That’s it. If you call your index.html you will get all the details in real time.

Happy analyzing!

Author
Categories Web, Server