diff --git a/hosts/ildkule/services/metrics/default.nix b/hosts/ildkule/services/metrics/default.nix index 3493e56..a0a6a40 100644 --- a/hosts/ildkule/services/metrics/default.nix +++ b/hosts/ildkule/services/metrics/default.nix @@ -2,7 +2,7 @@ { imports = [ - ./prometheus.nix + ./prometheus ./grafana.nix ./loki.nix ]; diff --git a/hosts/ildkule/services/metrics/prometheus.nix b/hosts/ildkule/services/metrics/prometheus.nix deleted file mode 100644 index 90bba88..0000000 --- a/hosts/ildkule/services/metrics/prometheus.nix +++ /dev/null @@ -1,68 +0,0 @@ -{ config, pkgs, ... }: - -let - cfg = config.services.prometheus; -in { - services.prometheus = { - enable = true; - listenAddress = "127.0.0.1"; - port = 9001; - - 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" - "jokum.pvv.ntnu.no:9100" - ]; - } - ]; - } - { - job_name = "synapse"; - scrape_interval = "15s"; - scheme = "https"; - http_sd_configs = [ - { - url = "https://matrix.pvv.ntnu.no/metrics/config.json"; - } - ]; - relabel_configs = [ - { - source_labels = [ "__address__" ]; - regex = "[^/]+(/.*)"; - target_label = "__metrics_path__"; - } - { - source_labels = [ "__address__" ]; - regex = "([^/]+)/.*"; - target_label = "instance"; - } - { - source_labels = [ "__address__" ]; - regex = "[^/]+\\/+[^/]+/(.*)/\\d+$"; - target_label = "job"; - } - { - source_labels = [ "__address__" ]; - regex = "[^/]+\\/+[^/]+/.*/(\\d+)$"; - target_label = "index"; - } - { - source_labels = [ "__address__" ]; - regex = "([^/]+)/.*"; - target_label = "__address__"; - } - ]; - } - ]; - ruleFiles = [ rules/synapse-v2.rules ]; - }; -} diff --git a/hosts/ildkule/services/metrics/prometheus/default.nix b/hosts/ildkule/services/metrics/prometheus/default.nix new file mode 100644 index 0000000..21f689b --- /dev/null +++ b/hosts/ildkule/services/metrics/prometheus/default.nix @@ -0,0 +1,14 @@ +{ config, ... }: { + imports = [ + ./node.nix + ./matrix-synapse.nix + ]; + + services.prometheus = { + enable = true; + listenAddress = "127.0.0.1"; + port = 9001; + + ruleFiles = [ rules/synapse-v2.rules ]; + }; +} diff --git a/hosts/ildkule/services/metrics/prometheus/matrix-synapse.nix b/hosts/ildkule/services/metrics/prometheus/matrix-synapse.nix new file mode 100644 index 0000000..8a9f400 --- /dev/null +++ b/hosts/ildkule/services/metrics/prometheus/matrix-synapse.nix @@ -0,0 +1,40 @@ +{ ... }: +{ + services.prometheus.scrapeConfigs = [{ + job_name = "synapse"; + scrape_interval = "15s"; + scheme = "https"; + + http_sd_configs = [{ + url = "https://matrix.pvv.ntnu.no/metrics/config.json"; + }]; + + relabel_configs = [ + { + source_labels = [ "__address__" ]; + regex = "[^/]+(/.*)"; + target_label = "__metrics_path__"; + } + { + source_labels = [ "__address__" ]; + regex = "([^/]+)/.*"; + target_label = "instance"; + } + { + source_labels = [ "__address__" ]; + regex = "[^/]+\\/+[^/]+/(.*)/\\d+$"; + target_label = "job"; + } + { + source_labels = [ "__address__" ]; + regex = "[^/]+\\/+[^/]+/.*/(\\d+)$"; + target_label = "index"; + } + { + source_labels = [ "__address__" ]; + regex = "([^/]+)/.*"; + target_label = "__address__"; + } + ]; + }]; +} diff --git a/hosts/ildkule/services/metrics/prometheus/node.nix b/hosts/ildkule/services/metrics/prometheus/node.nix new file mode 100644 index 0000000..23a1969 --- /dev/null +++ b/hosts/ildkule/services/metrics/prometheus/node.nix @@ -0,0 +1,20 @@ +{ 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" + "jokum.pvv.ntnu.no:9100" + ]; + } + ]; + }]; +} diff --git a/hosts/ildkule/services/metrics/rules/synapse-v2.rules b/hosts/ildkule/services/metrics/prometheus/rules/synapse-v2.rules similarity index 100% rename from hosts/ildkule/services/metrics/rules/synapse-v2.rules rename to hosts/ildkule/services/metrics/prometheus/rules/synapse-v2.rules