Traefik’s dashboard is a great tool to diagnose routing issues, and check services are being detected correctly, but it can’t do much more than that. It doesn’t show any metrics. Instead, it relies (arguably correctly) on external monitoring tools for metrics.
Traefik supports 4 metric backends: Datadog, Prometheus, StatsD and InfluxDB. InfluxDB is the tool I’m going to be integrating, as I already know how to work with it. I recently set up Traefik to export metrics into InfluxDB, to then be reported on using Grafana.
By default, Traefik uses UDP to push data into InfluxDB rather than HTTP, due to its lower latency and “fire and forget” nature, although this is configurable. InfluxDB’s container doesn’t listen for UDP traffic by default, so it’ll need to be made to:
Because I run Traefik in host mode, the networking set up is a little different to normal. Usually containers in the same docker-compose.yml file can communicate over the default network just fine, but because Traefik is in host mode this doesn’t work. Instead, I bind InfluxDB to listen on a local port on the host, and point Traefik at that:
We expose 2 ports here because Traefik will be using UDP, and Grafana requires HTTP. We could change Traefik to use HTTP, but using the default felt a lot simpler, and reduces overhead.
Next, we need to create the Grafana data source for InfluxDB. This works in the same way as adding other data sources, just be sure to add the HTTP port (8086) for InfluxDB, not UDP (8089).
Using Grafana’s “Explore” page, we can take a look at the data being provided by Traefik. There are several metrics output, but the one I focus most on is traefik.service.requests.total, which tallies requests for each service.
The above query will show you the number of requests per $__interval hitting each of your services.
The documentation on what exactly count means is rather absent, but after some digging discovered it’s the number of requests hitting the service or entry point between each push from Traefik. I’ve set this to 1 minute to make calculations and graphing easier, but depending on scale you may want to adjust that, or the GROUP BY time() statement.
Now, you’ve got metrics about your Traefik instances into Grafana for future graphing and querying needs. You can set up alerting, cross-reference graphs, and everything else Grafana has to offer.
I’ve been using Traefik for a while now, and I’ve helped quite a few people with it, but I still see a lot of people scared off it. This isn’t helped by a lot of guides being incredibly verbose, and not explaining what’s going on very well. Most people I…
Traefik is a cloud native reverse proxy, which is basically a fancy way of saying it’s a reverse proxy with some fancy features. Specifically it has fancy features around auto-discovery, and deep integration with technologies like Docker and Kubernetes.Basic concepts Traefik has four fundamental concepts: Entrypoints, routers, middleware and services.…
Recently, I decided to put some analytics on my website. Would be nice to see what view number are like and what pages get the most traffic. Most people would just stick Google Analytics on and be done with. But the privacy implications off that are huge and terrible, not…