• Stars
    star
    309
  • Rank 135,306 (Top 3 %)
  • Language
  • Created over 7 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A Docker Swarm Stack for monitoring Traefik with Promethues and Grafana

Monitor Traefik with Prometheus

This Repo helps you get started with monitoring Traefik v2.0the amazing Reverse Proxy + so much more. Along with Traefik we will provision Prometheus for Time Series Data collection and Grafana for Visualization. Traefik will also act as a proxy in front of Promethues and Grafana while Prometheus monitors Traefik the other way. Cool, huh?

Before we can begin ensure you have Docker installed with Docker Swarm enabled. If you are using Docker for Desktop Mac or Windows you already have Swarm enabled. For all others please follow the Swarm setup guide.

The presentation and Video from this demo is also included in the Repo - 56k_Cloud_Traefik_Monitoring.pdf and Youtube Session

Traefik Diagram

Goals of the Traefik Monitoring Repo:

  • Provision a Traefik Stack with Prometheus metrics enabled
  • Deploy Prometheus & Grafana
  • Verify Traefik Metrics
  • Configure Dashboards in Grafana for Traefik

Review the Traefik Monitoring Stack Deployment

In this section we will prepare and deploy our Traefik Reverse Proxy and our monitoring stack.

First, we need to clone this Repo to your Docker Swarm. Ensure you are performing this on your Manager node. If you only have one node then this is also the manager.

git clone https://github.com/vegasbrianc/docker-traefik-prometheus.git

Next, lets review what the stack is doing before we deploy it. With your favorite editor (vim of course). Open the docker-compose.yml file.

cd docker-traefik-prometheus
vi docker-compose.yml

The Traefik metrics are enabled by the command we pass to the Traefik container. The --metrics flag enables metrics and --metrics.prometheus.buckets=0.1,0.3,1.2,5.0 defines the Prometheus bucket value (typically in seconds). Prometheus monitors for all values and stores the metric in the appropriate bucket.

version: '3.7'

services:
traefik:
    image: traefik:v2.0
    command:
    - "--logLevel=DEBUG"
    - "--api"
    - "--metrics"
    - "--metrics.prometheus.buckets=0.1,0.3,1.2,5.0"
    - "--docker"
    - "--docker.swarmMode"
    - "--docker.domain=docker.localhost"
    - "--docker.watch"

Grafana and Prometheus are being deployed by Docker Swarm and the networking is managed by Traefik. We use labels for the services deployed to inform Traefik how to setup the frontend and backend for each service.

Grafana Deployment

deploy:
 labels:
  - "traefik.port=3000"
  - "traefik.docker.network=inbound"
  -  "traefik.frontend.rule=Host:grafana.localhost"

Prometheus Deployment

deploy:
  labels:
   - "traefik.frontend.rule=Host:prometheus.localhost"
   - "traefik.port=9090"
   - "traefik.docker.network=inbound"

Prometheus is also configured to monitor Traefik. This is configured in Prometheus.yml which enables Prometheus to auto-discover Traefik inside of Docker Swarm. Prometheus is watching for the Service Task tasks.traefik on port 8080. Once the service is online metrics will begin flowing to Prometheus.

Deploy Traefik, Prometheus, and Grafana

OK, we now know where everything is configured inside of the stack. The moment of truth DEPLOY

In the docker-traefik-prometheusdirectory run the following:

docker stack deploy -c docker-compose.yml traefik

Verify all the services have been provisioned. The Replica count for each service should be 1/1 Note this can take a couple minutes

docker service ls

Check the Metrics

Once all the services are up we can open the Traefik Dashboard. The dashboard should show us our frontend and backends configured for both Grafana and Prometheus.

http://docker.localhost:8080/

Take a look at the metrics which Traefik is now producing in Prometheus metrics format

http://localhost:8080/metrics

Login to Grafana and Visualize Metrics

Grafana is an Open Source visualization tool for the metrics collected with Prometheus. Next, open Grafana to view the Traefik Dashboards. Note: Firefox doesn't properly work with the below URLS please use Chrome

http://grafana.localhost

Username: admin Password: foobar

Open the Traefik Dashboard and select the different backends available

Note: Upper right-hand corner of Grafana switch the default 1 hour time range down to 5 minutes. Refresh a couple times and you should see data start flowing

Deploy a new webservice

Of course we couldn't do a demo without showing some Cat Gifs. This demo launches a random cat picture of the day served by three instances of the Cats Services.

docker stack deploy -c cats.yml cats

Let's have a look at our new service

http://cats.localhost

Refresh a few times and notice the Traefik Proxy is loadbalancing our requests to the 3 different Cat services.

Now, head back to Grafana. Refresh the Traefik dashboard in the upper right corner and set 5 minutes for our time range. Select, the Cats backend in the Dashboard.

More Repositories

1

prometheus

A docker-compose stack for Prometheus monitoring
4,349
star
2

docker-monitoring

Docker-Monitoring based on Cadvisor, InfluxDB, and Grafana
465
star
3

github-monitoring

Monitor your GitHub Repos with Docker & Prometheus
261
star
4

docker-compose-demo

A short demo on how to use Docker Compose to create a Web Service connected to a load balancer and a Redis Database.
Python
179
star
5

grafana_dashboard

A Grafana Dashboard for monitoring Docker with Prometheus
58
star
6

crypto-currency-tracker

Track your Crypto Currencies with this Docker & Prometheus Stack
54
star
7

docker-pulls

A simple compose script to use in conjunction with the prometheus stack to monitor Docker pulls.
20
star
8

mac-background

A Python script which grabs random images from Unsplash and set it as your Mac OSX background image
Python
14
star
9

traefik-ghost

A Docker Stack using Traefik Proxy & Ghost 1.x
5
star
10

Ghost-Standalone

A Docker powered Ghost installation with volumes
CSS
4
star
11

vscode-docker-demo

Demo code for the DockerCon VS Code demo
Python
4
star
12

docker-ch-meetup10

10th Docker Switzerland User Group Meetup Docker Swarm Demo
4
star
13

webslides

A Dockerized version of http://www.Webslides.tv
4
star
14

docker-LAMP

A small Docker LAMP stack
3
star
15

docker-ecs-demo

This is a demo repo for deploying containers directly to AWS ECS
Python
3
star
16

linux_tweet_app

This a demo autobuild
HTML
2
star
17

traefik-migration

A Repo to help you migrate Traefik from 1.7 to 2.x
2
star
18

vegasbrianc

1
star
19

hugo

The really cool Hugo Static Website generator Dockerized
1
star
20

prom

Prometheus Docker Build
1
star
21

K8s-demo

Docker Kuberenetes Stack Demo
1
star