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!
Comments
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
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.logAnother 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 -You can also use GoAccess to analyse response times from PHP based on the PHP access log. The log format here is quite different but the configuration options in GoAccess makes it quite flexible.
platform log php.access --tail 2>/dev/null | goaccess --datetime-format='%Y-%m-%dT%H:%M:%SZ' --log-format='%x %m %s %L.%^ %h %^ %^ %^%r' --no-ip-validationPlease sign in to leave a comment.