From a70735057e2e5b64e0172d01bf5f74118cd3b346 Mon Sep 17 00:00:00 2001 From: Franck Cuny Date: Wed, 2 Mar 2022 17:38:34 -0800 Subject: prometheus: relabel some machines Don't use the IP from wireguard as the name of the host, let's map to the actual hostname. --- hosts/common/server/prometheus.nix | 32 ++++++++++++++++++++------------ 1 file changed, 20 insertions(+), 12 deletions(-) (limited to 'hosts/common') diff --git a/hosts/common/server/prometheus.nix b/hosts/common/server/prometheus.nix index 1c7c906..a27e3cc 100644 --- a/hosts/common/server/prometheus.nix +++ b/hosts/common/server/prometheus.nix @@ -1,12 +1,5 @@ { config, pkgs, lib, ... }: -let - # Scrape a list of static targets for a job. - staticScrape = (job_name: targets: { - inherit job_name; - static_configs = [{ inherit targets; }]; - }); -in { services.prometheus = { enable = true; @@ -15,15 +8,30 @@ in extraFlags = [ # 3 years of retention - "--storage.tsdb.retention=1095d" + "--storage.tsdb.retention=${toString (365 * 3)}d" "--web.enable-admin-api" ]; scrapeConfigs = [ - (staticScrape "node" [ - "rtr:9100" - "tahoe:9100" - ]) + { + job_name = "node"; + static_configs = [ + {targets = ["192.168.6.10:9100" "192.168.6.20:9100"]; } + ]; + relabel_configs = [{ + source_labels = ["__address__"]; + target_label = "instance"; + replacement = "nas"; + action = "replace"; + regex = "192\.168\.6\.10:(.*)"; + } { + source_labels = ["__address__"]; + target_label = "instance"; + replacement = "tahoe"; + action = "replace"; + regex = "192\.168\.6\.20:(.*)"; + }]; + } ]; }; } -- cgit 1.4.1