2025-04-09 15:31:18 +02:00
|
|
|
{
|
|
|
|
config,
|
|
|
|
lib,
|
|
|
|
pkgs,
|
|
|
|
...
|
2025-07-20 01:23:48 +02:00
|
|
|
}:
|
|
|
|
let
|
2025-04-09 15:31:18 +02:00
|
|
|
inherit (lib.modules) mkIf;
|
|
|
|
inherit (lib.options) mkEnableOption;
|
|
|
|
|
2025-04-09 15:31:18 +02:00
|
|
|
cfg = config.modules.system.services.prometheus;
|
2025-04-09 15:31:18 +02:00
|
|
|
port = 4022;
|
2025-07-20 01:23:48 +02:00
|
|
|
in
|
|
|
|
{
|
2025-04-09 15:31:18 +02:00
|
|
|
options.modules.system.services.prometheus.enable = mkEnableOption "Grafana, a graphing service";
|
|
|
|
|
|
|
|
config = mkIf cfg.enable {
|
|
|
|
services.prometheus = {
|
|
|
|
enable = true;
|
|
|
|
package = pkgs.prometheus;
|
|
|
|
inherit port;
|
|
|
|
|
|
|
|
exporters = {
|
|
|
|
node = {
|
|
|
|
enable = true;
|
|
|
|
port = 4023;
|
2025-07-20 01:23:48 +02:00
|
|
|
enabledCollectors = [
|
|
|
|
"systemd"
|
|
|
|
"processes"
|
|
|
|
];
|
2025-04-09 15:31:18 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
postgres = {
|
|
|
|
enable = true;
|
|
|
|
port = 4024;
|
|
|
|
user = "postgres";
|
|
|
|
};
|
2025-04-09 15:31:18 +02:00
|
|
|
nginx = {
|
|
|
|
enable = true;
|
|
|
|
port = 4025;
|
|
|
|
};
|
2025-04-09 15:31:18 +02:00
|
|
|
};
|
|
|
|
scrapeConfigs = [
|
|
|
|
{
|
|
|
|
job_name = "prometheus";
|
|
|
|
scrape_interval = "30s";
|
2025-07-20 01:23:48 +02:00
|
|
|
static_configs = [ { targets = [ "localhost:${toString port}" ]; } ];
|
2025-04-09 15:31:18 +02:00
|
|
|
}
|
|
|
|
{
|
|
|
|
job_name = "node";
|
|
|
|
scrape_interval = "30s";
|
2025-07-20 01:23:48 +02:00
|
|
|
static_configs = [
|
|
|
|
{ targets = [ "localhost:${toString config.services.prometheus.exporters.node.port}" ]; }
|
|
|
|
];
|
2025-04-09 15:31:18 +02:00
|
|
|
}
|
|
|
|
{
|
|
|
|
job_name = "postgres";
|
|
|
|
scrape_interval = "30s";
|
2025-07-20 01:23:48 +02:00
|
|
|
static_configs = [
|
|
|
|
{ targets = [ "localhost:${toString config.services.prometheus.exporters.postgres.port}" ]; }
|
|
|
|
];
|
2025-04-09 15:31:18 +02:00
|
|
|
}
|
2025-04-09 15:31:18 +02:00
|
|
|
{
|
|
|
|
job_name = "nginx";
|
|
|
|
scrape_interval = "30s";
|
2025-07-20 01:23:48 +02:00
|
|
|
static_configs = [
|
|
|
|
{ targets = [ "localhost:${toString config.services.prometheus.exporters.nginx.port}" ]; }
|
|
|
|
];
|
2025-04-09 15:31:18 +02:00
|
|
|
}
|
2025-04-09 15:31:18 +02:00
|
|
|
];
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|