How to visualize Access Logs with a fancy interface and charts

How to visualize Access Logs with a fancy interface and charts

Logs are important, you can push your logs to Logz.io as described here: https://community.platform.sh/t/how-to-forward-platform-sh-logs-to-logz-io/197

But what if you just want to visualize the Access Logs to have an overview of the visits? And what if you could do that from within your terminal and/or in your browser?

Introducing GoAccess.io! This tool is really handy and perfect to do that with no hassle.

Steps

Installation

Install the GoAccess locally. https://goaccess.io/download

It is available most of the Linux distribution, *BSD, even Slackware! Via Brew, or via Sources.

Just use it

Thanks to the platform CLI:

platform log access --tail | goaccess --log-format=COMBINED -

You will visualize in your terminal, or you can visualize it in your browser

platform log access --tail | goaccess --log-format=COMBINED -o report.html --real-time-html -

And then just open the report.html file.

Bonus that’s realtime if you pass the option --real-time-html

Advanced

If you want to have the full log, you can also download the full access.log

platform ssh --all # to see the SSH_URL
scp SSH_URL:/var/log/access.log .
goaccess access.log --log-format=COMBINED -o report.html

That’s it!
Enjoy fancy Access Log visualization!

4 Likes

Note that we do trim logs and this means it might be that the first line of the log file is not correctly formatted.
When running the above, you could end up with an error like

goaccess access.log --log-format=COMBINED -o report.html
access.log [0] [0/s]
Parsed 1 linesproducing the following errors:

Token 'lessChrome/87.0.4280.141' doesn't match specifier '%h'

Format Errors - Verify your log/date/time format

To resolve this, simply remove the first line of the log file like this (this will create a new file, change the below however you feel like):
tail -n +2 access.log > access.log.withoutfirstline.log

1 Like

Another option for filtering out the initial output from the platform.sh log command is to redirect stderr:

platform log access --tail 2>/dev/null | goaccess --log-format=COMBINED -