From 4bd78856e7b4bc63ca281b21ea03de2e9385b742 Mon Sep 17 00:00:00 2001 From: jasmine Date: Thu, 6 Jun 2024 20:45:31 +0800 Subject: [PATCH] Expose traefik metrics to prometheus. --- nixos/viridian/services/traefik/default.nix | 25 +++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/nixos/viridian/services/traefik/default.nix b/nixos/viridian/services/traefik/default.nix index 124e613..d8e729e 100644 --- a/nixos/viridian/services/traefik/default.nix +++ b/nixos/viridian/services/traefik/default.nix @@ -89,6 +89,21 @@ ]; }; }; + # Used to expose metrics + metrics = { + address = ":8082"; + }; + }; + + # Provide metrics for the prometheus backend + metrics = { + prometheus = { + entryPoint = "metrics"; + buckets = [ "0.1" "0.3" "1.2" "5.0" ]; + addEntryPointsLabels = true; + addRoutersLabels = true; + addServicesLabels = true; + }; }; # Retrieve certificates from an ACME server @@ -118,6 +133,16 @@ }; }; + # Scrape our traefik metrics + services.prometheus.scrapeConfigs = [ + { + job_name = "traefik"; + static_configs = [{ + targets = [ "127.0.0.1:8082" ]; + }]; + } + ]; + # Persist our traefik data & logs environment.persistence."/persist" = { directories = [