diff --git a/nixos/prometheus.nix b/nixos/prometheus.nix index f786506..24f71b4 100644 --- a/nixos/prometheus.nix +++ b/nixos/prometheus.nix @@ -12,42 +12,39 @@ services.prometheus = { enable = true; - scrapeConfigs = ( - let - generated = lib.pipe nodes [ - (lib.filterAttrs (name: node: node.config.services.prometheus.exporters.node.enable)) - (lib.attrsets.mapAttrsToList - (name: node: { - job_name = name; - static_configs = [ - { - targets = ["${node.config.networking.fqdn}:${toString node.config.services.prometheus.exporters.node.port}"]; - } - ]; - })) + scrapeConfigs = let + node = { + job_name = "node"; + static_configs = [ + { + targets = lib.pipe nodes [ + (lib.filterAttrs (_name: node: node.config.services.prometheus.exporters.node.enable)) + (lib.attrsets.mapAttrsToList + (_name: node: "${node.config.networking.fqdn}:${toString node.config.services.prometheus.exporters.node.port}")) + ]; + } ]; + }; - pikvm = { - job_name = "pikvm"; - metrics_path = "/api/export/prometheus/metrics"; - scheme = "https"; - tls_config.insecure_skip_verify = true; + pikvm = { + job_name = "pikvm"; + metrics_path = "/api/export/prometheus/metrics"; + scheme = "https"; + tls_config.insecure_skip_verify = true; - # We don't care about security here, it's behind a VPN. - basic_auth = { - username = "admin"; - password = "admin"; - }; - - static_configs = [ - { - targets = ["pikvm.dmz"]; - } - ]; + # We don't care about security here, it's behind a VPN. + basic_auth = { + username = "admin"; + password = "admin"; }; - in - generated ++ [pikvm] - ); + + static_configs = [ + { + targets = ["pikvm.dmz"]; + } + ]; + }; + in [node pikvm]; }; services.nginx = {