also refactor nixos modules
This commit is contained in:
parent
2471562583
commit
b37c5c0cbd
44 changed files with 10 additions and 2 deletions
51
modules/nixos/services/observability/prometheus.nix
Normal file
51
modules/nixos/services/observability/prometheus.nix
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
{
|
||||
pkgs,
|
||||
config,
|
||||
lib,
|
||||
...
|
||||
}: let
|
||||
inherit (builtins) toString;
|
||||
inherit (lib) mkIf mkEnableOption;
|
||||
|
||||
cfg = config.sneeuwvlok.services.observability.prometheus;
|
||||
in {
|
||||
options.sneeuwvlok.services.observability.prometheus = {
|
||||
enable = mkEnableOption "enable Prometheus";
|
||||
};
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
services.prometheus = {
|
||||
enable = true;
|
||||
port = 9002;
|
||||
|
||||
globalConfig.scrape_interval = "15s";
|
||||
|
||||
scrapeConfigs = [
|
||||
{
|
||||
job_name = "prometheus";
|
||||
static_configs = [
|
||||
{targets = ["localhost:9002"];}
|
||||
];
|
||||
}
|
||||
|
||||
{
|
||||
job_name = "node";
|
||||
static_configs = [
|
||||
{targets = ["localhost:${toString config.services.prometheus.exporters.node.port}"];}
|
||||
];
|
||||
}
|
||||
];
|
||||
|
||||
exporters = {
|
||||
node = {
|
||||
enable = true;
|
||||
port = 9005;
|
||||
enabledCollectors = ["systemd"];
|
||||
openFirewall = true;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
networking.firewall.allowedTCPPorts = [9002];
|
||||
};
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue