Out of principle I refuse to put any type of analytics on my sites. I don’t want to send user data to third parties and I don’t want to rely on data that comes from JavaScript on the browser unless strictly necessary.
But the thought recently occurred to me that I could use my server logs to create some basic data visualisation on Grafana.
I’d like very basic stuff:
- hits
- common referrers
- geo location by IP address
- bounce rates per page
What would be the recommended way to get this, assuming that I have traefik logs aggregates via Loki and Grafana installed?
Professionally, I’ve spent the last year almost entirely focused on o11y, a numeronym for observability. IMO you want to run opentelemetry (aka otel) for a lot of this stuff. It’s a fantastic tool. We tell clients that if they don’t use otel, then they’re probably doing o11y wrong.
You can run it as a collector to scrape log files. If your apps are instrumented, they can emit telemetry via OTLP to otel instead. Then otel can process and export the data to various data backends like Minor (metrics), Loki (logs), and Tempo (traces). Then use Grafana for a UI. That particular set of tools is known as the LGTM stack. if you only want to handle logs, your stack could be simpler: otel, Loki, and Grafana.
A final thought is about a seeming want for metrics generated from logs. Otel can do that for you too.