From 47d7b88a05abdeb66eda87e1541cb938f66588b2 Mon Sep 17 00:00:00 2001 From: Daniel Olsen Date: Thu, 5 Sep 2024 14:14:28 +0200 Subject: [PATCH] ildkule/prometheus: consolidate scrape jobs and label with hostname for base info --- .../monitoring/prometheus/default.nix | 3 +- .../monitoring/prometheus/machines.nix | 54 +++++++++++++++++++ .../services/monitoring/prometheus/node.nix | 22 -------- .../monitoring/prometheus/systemd.nix | 18 ------- 4 files changed, 55 insertions(+), 42 deletions(-) create mode 100644 hosts/ildkule/services/monitoring/prometheus/machines.nix delete mode 100644 hosts/ildkule/services/monitoring/prometheus/node.nix delete mode 100644 hosts/ildkule/services/monitoring/prometheus/systemd.nix diff --git a/hosts/ildkule/services/monitoring/prometheus/default.nix b/hosts/ildkule/services/monitoring/prometheus/default.nix index 6f3f95e4..cd4e4a91 100644 --- a/hosts/ildkule/services/monitoring/prometheus/default.nix +++ b/hosts/ildkule/services/monitoring/prometheus/default.nix @@ -4,9 +4,8 @@ ./matrix-synapse.nix # TODO: enable once https://github.com/NixOS/nixpkgs/pull/242365 gets merged # ./mysqld.nix - ./node.nix ./postgres.nix - ./systemd.nix + ./machines.nix ]; services.prometheus = { diff --git a/hosts/ildkule/services/monitoring/prometheus/machines.nix b/hosts/ildkule/services/monitoring/prometheus/machines.nix new file mode 100644 index 00000000..21028e25 --- /dev/null +++ b/hosts/ildkule/services/monitoring/prometheus/machines.nix @@ -0,0 +1,54 @@ +{ config, ... }: let + cfg = config.services.prometheus; +in { + services.prometheus.scrapeConfigs = [{ + job_name = "base_info"; + static_configs = [ + { labels.hostname = "ildkule"; + targets = [ + "ildkule.pvv.ntnu.no:${toString cfg.exporters.node.port}" + "ildkule.pvv.ntnu.no:${toString cfg.exporters.systemd.port}" + ]; + } + { labels.hostname = "bekkalokk"; + targets = [ + "bekkalokk.pvv.ntnu.no:9100" + "bekkalokk.pvv.ntnu.no:9101" + ]; + } + { labels.hostname = "bicep"; + targets = [ + "bicep.pvv.ntnu.no:9100" + "bicep.pvv.ntnu.no:9101" + ]; + } + { labels.hostname = "brzeczyszczykiewicz"; + targets = [ + "brzeczyszczykiewicz.pvv.ntnu.no:9100" + "brzeczyszczykiewicz.pvv.ntnu.no:9101" + ]; + } + { labels.hostname = "georg"; + targets = [ + "georg.pvv.ntnu.no:9100" + "georg.pvv.ntnu.no:9101" + ]; + } + { labels.hostname = "hildring"; + targets = [ + "hildring.pvv.ntnu.no:9100" + ]; + } + { labels.hostname = "isvegg"; + targets = [ + "isvegg.pvv.ntnu.no:9100" + ]; + } + { labels.hostname = "microbel"; + targets = [ + "microbel.pvv.ntnu.no:9100" + ]; + } + ]; + }]; +} diff --git a/hosts/ildkule/services/monitoring/prometheus/node.nix b/hosts/ildkule/services/monitoring/prometheus/node.nix deleted file mode 100644 index be62f7bc..00000000 --- a/hosts/ildkule/services/monitoring/prometheus/node.nix +++ /dev/null @@ -1,22 +0,0 @@ -{ config, ... }: let - cfg = config.services.prometheus; -in { - services.prometheus.scrapeConfigs = [{ - job_name = "node"; - static_configs = [ - { - targets = [ - "ildkule.pvv.ntnu.no:${toString cfg.exporters.node.port}" - "microbel.pvv.ntnu.no:9100" - "isvegg.pvv.ntnu.no:9100" - "knakelibrak.pvv.ntnu.no:9100" - "hildring.pvv.ntnu.no:9100" - "bicep.pvv.ntnu.no:9100" - "essendrop.pvv.ntnu.no:9100" - "andresbu.pvv.ntnu.no:9100" - "bekkalokk.pvv.ntnu.no:9100" - ]; - } - ]; - }]; -} diff --git a/hosts/ildkule/services/monitoring/prometheus/systemd.nix b/hosts/ildkule/services/monitoring/prometheus/systemd.nix deleted file mode 100644 index 6361c431..00000000 --- a/hosts/ildkule/services/monitoring/prometheus/systemd.nix +++ /dev/null @@ -1,18 +0,0 @@ -{ config, ... }: let - cfg = config.services.prometheus; -in { - services.prometheus.scrapeConfigs = [{ - job_name = "systemd"; - static_configs = [ - { - targets = [ - "ildkule.pvv.ntnu.no:${toString cfg.exporters.node.port}" - "bicep.pvv.ntnu.no:9101" - "bekkalokk.pvv.ntnu.no:9101" - "brzeczyszczykiewicz.pvv.ntnu.no:9101" - "georg.pvv.ntnu.no:9101" - ]; - } - ]; - }]; -}