feat: add prometheus config

This commit is contained in:
Katharina Heidenreich 2026-04-11 13:17:18 +02:00
parent 3f517bbe7f
commit d37716f72e
3 changed files with 43 additions and 0 deletions

View file

@ -11,4 +11,22 @@ rec {
"processes"
];
};
prometheus = {
port = 9090;
scrapeConfigs = {
node = {
scrape_interval = "60s";
metrics_path = "/metrics";
static_configs = [
{
targets = [
"localhost:9100/metrics"
"pi.home:9100/metrics"
];
}
];
};
};
};
}

View file

@ -4,5 +4,6 @@
./openssh.nix
./forgejo.nix
./node-exporter.nix
./prometheus.nix
];
}

24
services/prometheus.nix Normal file
View file

@ -0,0 +1,24 @@
{lib, ...}:
let
serv = import ../config/services.nix;
conf = lib.attrsets.mapAttrsToList (name: cfg: {
job_name = name;
scrape_interval = cfg.scrape_interval;
metrics_path = cfg.metrics_path;
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 ];
}