From fc5aa70d2701b03ea155018239bf33c3382c35df Mon Sep 17 00:00:00 2001 From: mirsal Date: Mon, 9 Aug 2021 23:28:15 +0000 Subject: [PATCH] Allow prometheus metrics collection This patch adds a METRICS_ENABLED configuration variables which, when switched on, defines a metrics entrypoint and enables the built-in prometheus metrics exporter. This allows the monitoring stack to collect and show traefik metrics --- .env.sample | 8 ++++++++ abra.sh | 2 +- traefik.yml.tmpl | 10 ++++++++++ 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/.env.sample b/.env.sample index e4b9981..1e19c25 100644 --- a/.env.sample +++ b/.env.sample @@ -53,6 +53,14 @@ COMPOSE_FILE="compose.yml" #COMPOSE_FILE="$COMPOSE_FILE:compose.keycloak.yml" #KEYCLOAK_MIDDLEWARE_ENABLED=1 +##################################################################### +# Prometheus metrics # +##################################################################### + +## Enable prometheus metrics collection +## used used by the coop-cloud monitoring stack +#METRICS_ENABLED=1 + ##################################################################### # Additional services # ##################################################################### diff --git a/abra.sh b/abra.sh index b38710a..4c03f07 100644 --- a/abra.sh +++ b/abra.sh @@ -1,3 +1,3 @@ -export TRAEFIK_YML_VERSION=v11 +export TRAEFIK_YML_VERSION=v12 export FILE_PROVIDER_YML_VERSION=v2 export ENTRYPOINT_VERSION=v2 diff --git a/traefik.yml.tmpl b/traefik.yml.tmpl index 99a436e..bd30603 100644 --- a/traefik.yml.tmpl +++ b/traefik.yml.tmpl @@ -54,10 +54,20 @@ entrypoints: mumble-udp: address: ":64738/udp" {{ end }} + {{ if eq (env "METRICS_ENABLED") "1" }} + metrics: + address: ":8082" + {{ end }} ping: entryPoint: web +{{ if eq (env "METRICS_ENABLED") "1" }} +metrics: + prometheus: + entryPoint: metrics +{{ end }} + certificatesResolvers: staging: acme: