config/modules/services/node_exporter/default.nix

49 lines
991 B
Nix
Raw Normal View History

2023-08-18 09:31:19 +03:00
{
config,
lib,
myData,
...
2024-07-29 15:39:54 +03:00
}:
let
2023-09-18 19:29:27 +03:00
cfg = config.mj.services.node_exporter;
2024-07-29 15:39:54 +03:00
in
{
2023-08-18 09:31:19 +03:00
options.mj.services.node_exporter = with lib.types; {
enable = lib.mkEnableOption "Enable node_exporter";
2023-09-18 19:29:27 +03:00
extraSubnets = lib.mkOption {
type = listOf str;
2024-07-29 15:39:54 +03:00
default = [ ];
2023-09-18 19:29:27 +03:00
};
2023-08-18 09:31:19 +03:00
};
2023-09-18 19:29:27 +03:00
config = lib.mkIf cfg.enable {
2023-08-18 09:31:19 +03:00
services.prometheus.exporters.node = {
enable = true;
2024-07-29 15:39:54 +03:00
enabledCollectors = [
"systemd"
"processes"
];
2023-08-18 09:31:19 +03:00
port = myData.ports.exporters.node;
2023-08-25 09:55:21 +03:00
user = "node_exporter";
group = "node_exporter";
};
users.users.node_exporter = {
isSystemUser = true;
group = "node_exporter";
uid = myData.uidgid.node_exporter;
};
users.groups.node_exporter = {
gid = myData.uidgid.node_exporter;
2023-08-18 09:31:19 +03:00
};
2023-09-12 15:46:44 +03:00
mj.services.friendlyport.ports = [
{
2024-07-29 15:39:54 +03:00
subnets = [ myData.subnets.tailscale.cidr ] ++ cfg.extraSubnets;
tcp = [ myData.ports.exporters.node ];
2023-09-12 15:46:44 +03:00
}
2023-08-18 09:31:19 +03:00
];
};
}