prometheus/module.nix: init
This commit is contained in:
parent
734e30bc45
commit
524edd90ed
1 changed files with 57 additions and 0 deletions
57
modules/services/prometheus/module.nix
Normal file
57
modules/services/prometheus/module.nix
Normal file
|
@ -0,0 +1,57 @@
|
|||
{
|
||||
config,
|
||||
lib,
|
||||
pkgs,
|
||||
...
|
||||
}: let
|
||||
inherit (lib.modules) mkIf;
|
||||
inherit (lib.options) mkEnableOption;
|
||||
|
||||
cfg = config.modules.system.services.grafana;
|
||||
port = 4022;
|
||||
in {
|
||||
options.modules.system.services.prometheus.enable = mkEnableOption "Grafana, a graphing service";
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
networking.firewall.allowedTCPPorts = [config.services.grafana.settings.server.http_port];
|
||||
|
||||
modules.system.services.database.postgresql.enable = true;
|
||||
|
||||
services.prometheus = {
|
||||
enable = true;
|
||||
package = pkgs.prometheus;
|
||||
inherit port;
|
||||
|
||||
exporters = {
|
||||
node = {
|
||||
enable = true;
|
||||
port = 4023;
|
||||
enabledCollectors = ["systemd" "processes"];
|
||||
};
|
||||
|
||||
postgres = {
|
||||
enable = true;
|
||||
port = 4024;
|
||||
user = "postgres";
|
||||
};
|
||||
};
|
||||
scrapeConfigs = [
|
||||
{
|
||||
job_name = "prometheus";
|
||||
scrape_interval = "30s";
|
||||
static_configs = [{targets = ["localhost:${toString port}"];}];
|
||||
}
|
||||
{
|
||||
job_name = "node";
|
||||
scrape_interval = "30s";
|
||||
static_configs = [{targets = ["localhost:${toString config.services.prometheus.exporters.node.port}"];}];
|
||||
}
|
||||
{
|
||||
job_name = "postgres";
|
||||
scrape_interval = "30s";
|
||||
static_configs = [{targets = ["localhost:${toString config.services.prometheus.exporters.postgres.port}"];}];
|
||||
}
|
||||
];
|
||||
};
|
||||
};
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue