Traefik is just the tool that solves multiple use cases while at the same time reduce Dev and Ops efforts for deploying and maintaining applications. The goal we should be striving for is to make our lives easier, not more complicated. I am continually advocating to reduce the number of tools in our toolbox and reduce complexity. We are not all deploying Google, or Facebook size infrastructures are we?
Traefik is my top drawer tool to solve multiple use cases while not adding additional complexity. Need a Reverse Proxy, a Let's Encrypt integration, or a Docker Swarm/Kubernetes integration then Traefik is just the tool for the job. If you wander across the interwebs any length of time Googling the above topics chances are you will yourself stumble upon Traefik.
I have been using Traefik for quite some time across several projects. The first project I used Traefik for was this very website which at the time I was hosting on Digital Ocean, with Ghost, and Traefik running the reverse proxy and Lets Encrypt. The combination worked amazingly well and handled the front page of Hacker News.
Recently, I had the amazing opportunity to share how I use Traefik with my Docker Monitoring project. This project helps you get started with monitoring Traefik and deploying a monitoring stack all in one go. Along with Traefik, the Repo provisions Prometheus for Time Series Data collection and Grafana for Visualizations. Traefik acts as a proxy in front of Promethues and Grafana while Prometheus monitors Traefik the other way. Cool, huh?
Included in the deployment is some auto-provisioning magic which deploys some starter Data sources and Dashboards for Grafana. If you navigate to the Grafana Provisioning folder in the Repo, you can see how both the Data sources and Dashboards configurations.
Enable Metrics in Traefik
To activate metrics inside of Traefik, we need to pass the metrics flag inside the as seen in the docker-compose.yml gist below. To enable metrics as seen in the line, add the
--metrics. Next, we need to tell Traefik what kind of metrics should be enabled. In our case, we want to enable Prometheus metrics and tell Traefik to store the metrics in time series buckets
--metrics.prometheus.buckets=0.1,0.3,1.2,5.0 The bucket numbers indicate time slices of 0.1 seconds, 0.3, etc. So if a metric falls into a specific time range, it falls into that specific bucket. The bucket setting is the default setting.
Wrap up and Deploy It
The Repo is a skeleton on how to configure metrics and to enable and monitor Traefik. The Repo is the source for the instructions on how to deploy and configure in more detail and an additional Cats Gif webapp example for adding more workloads to Traefik to see how the visualizations update.
Enjoy the project, and be sure to open an issue if you have problems or questions. I try to keep the Repo the source of comments so others can learn as well.
Below you can find the slides from the Webinar with Traefik and the recorded YouTube session.