diff options
Diffstat (limited to 'hosts')
-rw-r--r-- | hosts/common/server/prometheus.nix | 32 |
1 files changed, 20 insertions, 12 deletions
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:(.*)"; + }]; + } ]; }; } |