From 688e6c35d3e4b98b3ec33f80d7902a976ba518b0 Mon Sep 17 00:00:00 2001 From: mirsal Date: Tue, 10 Aug 2021 01:06:41 +0000 Subject: [PATCH] prometheus: Enable collection of traefik metrics --- .env.sample | 4 ++++ abra.sh | 2 +- compose.yml | 3 ++- prometheus.yml => prometheus.yml.tmpl | 4 +++- 4 files changed, 10 insertions(+), 3 deletions(-) rename prometheus.yml => prometheus.yml.tmpl (92%) diff --git a/.env.sample b/.env.sample index 025b2a3..0dea8bc 100644 --- a/.env.sample +++ b/.env.sample @@ -5,6 +5,10 @@ PROMETHEUS_DOMAIN=prometheus.example.com LETS_ENCRYPT_ENV=production +# Edit this in order to allow collection of traefik metrics +#TRAEFIK_METRICS_ENABLED=1 +#TRAEFIK_SERVICE_NAME=traefik_app + # grafana SMTP configuration (optional) #GF_SMTP_HOST=changeme #GF_SMTP_ENABLED=1 diff --git a/abra.sh b/abra.sh index 9a14054..2011d6b 100644 --- a/abra.sh +++ b/abra.sh @@ -1,4 +1,4 @@ -export PROMETHEUS_YML_VERSION=v1 +export PROMETHEUS_YML_VERSION=v2 export PROMTAIL_YML_VERSION=v1 export LOKI_YML_VERSION=v1 export NODE_EXPORTER_ENTRYPOINT_VERSION=v1 diff --git a/compose.yml b/compose.yml index 0f99ae1..5b12154 100644 --- a/compose.yml +++ b/compose.yml @@ -145,8 +145,9 @@ services: configs: prometheus_yml: + template_driver: golang name: ${STACK_NAME}_prometheus_yml_${PROMETHEUS_YML_VERSION} - file: prometheus.yml + file: prometheus.yml.tmpl promtail_yml: name: ${STACK_NAME}_promtail_yml_${PROMTAIL_YML_VERSION} file: promtail.yml diff --git a/prometheus.yml b/prometheus.yml.tmpl similarity index 92% rename from prometheus.yml rename to prometheus.yml.tmpl index ad4e77d..2547b27 100644 --- a/prometheus.yml +++ b/prometheus.yml.tmpl @@ -46,11 +46,13 @@ scrape_configs: type: 'A' port: 8080 +{{ if eq (env "TRAEFIK_METRICS_ENABLED") "1" }} - job_name: 'traefik' scrape_interval: 30s metrics_path: '/metrics' dns_sd_configs: - names: - - 'tasks.traefik_app' + - 'tasks.{{ (env "TRAEFIK_SERVICE_NAME") }}' type: 'A' port: 8082 +{{ end }}