diff --git a/config/services.nix b/config/services.nix index d62ce92..de3c29c 100644 --- a/config/services.nix +++ b/config/services.nix @@ -11,4 +11,20 @@ rec { "processes" ]; }; + + prometheus = { + port = 9090; + scrapeConfigs = { + node = { + static_configs = [ + { + targets = [ + "localhost:9100" + "pi.home:9100" + ]; + } + ]; + }; + }; + }; } diff --git a/services/default.nix b/services/default.nix index 1e9cfb5..a87a956 100644 --- a/services/default.nix +++ b/services/default.nix @@ -4,5 +4,6 @@ ./openssh.nix ./forgejo.nix ./node-exporter.nix + ./prometheus.nix ]; } diff --git a/services/prometheus.nix b/services/prometheus.nix new file mode 100644 index 0000000..e5be99a --- /dev/null +++ b/services/prometheus.nix @@ -0,0 +1,20 @@ +{lib, ...}: +let + serv = import ../config/services.nix; + conf = lib.attrsets.mapAttrsToList (name: cfg: { + job_name = name; + + static_configs = cfg.static_configs; + }) serv.prometheus.scrapeConfigs; +in +{ + services.prometheus = { + enable = true; + + scrapeConfigs = conf; + + port = serv.prometheus.port; + }; + + networking.firewall.allowedTCPPorts = [ serv.prometheus.port ]; +} \ No newline at end of file