{"id":13469234,"url":"https://github.com/vegasbrianc/docker-traefik-prometheus","last_synced_at":"2025-04-06T16:15:55.524Z","repository":{"id":37430979,"uuid":"99771986","full_name":"vegasbrianc/docker-traefik-prometheus","owner":"vegasbrianc","description":"A Docker Swarm Stack for monitoring Traefik with Promethues and Grafana","archived":false,"fork":false,"pushed_at":"2019-11-26T22:09:08.000Z","size":24106,"stargazers_count":344,"open_issues_count":4,"forks_count":108,"subscribers_count":13,"default_branch":"master","last_synced_at":"2025-03-30T15:11:11.164Z","etag":null,"topics":["docker","docker-compose","docker-swarm","grafana","metrics","monitoring","prometheus","swarm","traefik"],"latest_commit_sha":null,"homepage":"","language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/vegasbrianc.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null},"funding":{"github":"vegasbrianc"}},"created_at":"2017-08-09T06:19:10.000Z","updated_at":"2025-03-26T00:29:03.000Z","dependencies_parsed_at":"2022-08-03T03:46:06.700Z","dependency_job_id":null,"html_url":"https://github.com/vegasbrianc/docker-traefik-prometheus","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vegasbrianc%2Fdocker-traefik-prometheus","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vegasbrianc%2Fdocker-traefik-prometheus/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vegasbrianc%2Fdocker-traefik-prometheus/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vegasbrianc%2Fdocker-traefik-prometheus/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/vegasbrianc","download_url":"https://codeload.github.com/vegasbrianc/docker-traefik-prometheus/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247509238,"owners_count":20950232,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["docker","docker-compose","docker-swarm","grafana","metrics","monitoring","prometheus","swarm","traefik"],"created_at":"2024-07-31T15:01:29.899Z","updated_at":"2025-04-06T16:15:55.470Z","avatar_url":"https://github.com/vegasbrianc.png","language":null,"funding_links":["https://github.com/sponsors/vegasbrianc"],"categories":["Misc","Others"],"sub_categories":[],"readme":"# Monitor Traefik with Prometheus\n\nThis Repo helps you get started with monitoring [Traefik v2.0](https://traefik.io/)the 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?\n\nBefore 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](https://docs.docker.com/engine/swarm/swarm-mode/).\n\nThe presentation and Video from this demo is also included in the Repo - [56k_Cloud_Traefik_Monitoring.pdf](https://github.com/vegasbrianc/docker-traefik-prometheus/blob/master/56k_Cloud_Traefik_Monitoring.pdf) and [Youtube Session](https://youtu.be/3q-K4JDcH6I)\n\n![Traefik Diagram](./img/Traefik-diagram.png)\n\n# Goals of the Traefik Monitoring Repo:\n\n* Provision a Traefik Stack with Prometheus metrics enabled\n* Deploy Prometheus \u0026 Grafana\n* Verify Traefik Metrics\n* Configure Dashboards in Grafana for Traefik\n\n## Review the Traefik Monitoring Stack Deployment\nIn this section we will prepare and deploy our Traefik Reverse Proxy and our monitoring stack. \n\nFirst, 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.\n\n    git clone https://github.com/vegasbrianc/docker-traefik-prometheus.git\n\nNext, lets review what the stack is doing before we deploy it. With your favorite editor (vim of course). Open the `docker-compose.yml` file.\n\n    cd docker-traefik-prometheus\n    vi docker-compose.yml\n\nThe 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.\n\n    version: '3.7'\n\n    services:\n    traefik:\n        image: traefik:v2.0\n        command:\n        - \"--logLevel=DEBUG\"\n        - \"--api\"\n        - \"--metrics\"\n        - \"--metrics.prometheus.buckets=0.1,0.3,1.2,5.0\"\n        - \"--docker\"\n        - \"--docker.swarmMode\"\n        - \"--docker.domain=docker.localhost\"\n        - \"--docker.watch\"\n\nGrafana 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.\n\n**Grafana Deployment**\n\n    deploy:\n     labels:\n      - \"traefik.port=3000\"\n      - \"traefik.docker.network=inbound\"\n      -  \"traefik.frontend.rule=Host:grafana.localhost\"\n\n**Prometheus Deployment**\n\n    deploy:\n      labels:\n       - \"traefik.frontend.rule=Host:prometheus.localhost\"\n       - \"traefik.port=9090\"\n       - \"traefik.docker.network=inbound\"\n\nPrometheus is also configured to monitor Traefik. This is configured in [Prometheus.yml](https://github.com/vegasbrianc/docker-traefik-prometheus/blob/master/prometheus/prometheus.yml#L40) 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.\n\n## Deploy Traefik, Prometheus, and Grafana\nOK, we now know where everything is configured inside of the stack. The moment of truth `DEPLOY`\n\nIn the `docker-traefik-prometheus`directory run the following:\n\n    docker stack deploy -c docker-compose.yml traefik\n\nVerify all the services have been provisioned. The Replica count for each service should be 1/1 \n**Note this can take a couple minutes**\n\n    docker service ls\n    \n## Check the Metrics\nOnce 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.\n\n    http://docker.localhost:8080/\n\n\nTake a look at the metrics which Traefik is now producing in Prometheus metrics format\n\n    http://localhost:8080/metrics\n\n\n## Login to Grafana and Visualize Metrics\nGrafana is an Open Source visualization tool for the metrics collected with Prometheus. Next, open Grafana to view the Traefik Dashboards.\n**Note: Firefox doesn't properly work with the below URLS please use Chrome**\n\n    http://grafana.localhost\n\nUsername: admin\nPassword: foobar\n\nOpen the Traefik Dashboard and select the different backends available\n\n**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**\n\n## Deploy a new webservice\nOf 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.\n\n    docker stack deploy -c cats.yml cats\n\nLet's have a look at our new service\n\n    http://cats.localhost\n\nRefresh a few times and notice the Traefik Proxy is loadbalancing our requests to the 3 different Cat services.\n\nNow, 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.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvegasbrianc%2Fdocker-traefik-prometheus","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvegasbrianc%2Fdocker-traefik-prometheus","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvegasbrianc%2Fdocker-traefik-prometheus/lists"}