cf600e2dc1
Might not work probably did smnth wrong
67 lines
1.3 KiB
Nix
67 lines
1.3 KiB
Nix
{
|
|
lib,
|
|
config,
|
|
...
|
|
}:
|
|
with lib; let
|
|
name = "prometheus";
|
|
cfg = config.services.skynet."${name}";
|
|
in {
|
|
imports = [];
|
|
|
|
options.services.skynet."${name}" = {
|
|
#list of servers passed in for monitoring
|
|
servers = mkOption {
|
|
type = types.listOf types.str;
|
|
};
|
|
|
|
server = {
|
|
enable = mkEnableOption "Prometheus Server";
|
|
host = {
|
|
ip = mkOption {
|
|
type = types.str;
|
|
};
|
|
|
|
name = mkOption {
|
|
type = types.str;
|
|
};
|
|
};
|
|
|
|
port = mkOption {
|
|
type = types.port;
|
|
default = 9001;
|
|
};
|
|
};
|
|
|
|
collecter_port = mkOption {
|
|
type = types.port;
|
|
default = 9002;
|
|
};
|
|
};
|
|
|
|
config =
|
|
{
|
|
services.prometheus.exporters.node = {
|
|
enable = true;
|
|
# most collectors are on by default see docs for more options
|
|
enabledCollectors = ["systemd"];
|
|
port = cfg.collecter_port;
|
|
};
|
|
}
|
|
// mkIf cfg.server.enable {
|
|
services.prometheus = {
|
|
enable = true;
|
|
port = cfg.server.port;
|
|
scrapeConfigs = [
|
|
{
|
|
job_name = "node_exporter";
|
|
static_configs = [
|
|
{
|
|
targets = map (server: "${server}.skynet.ie:{collecter_port}") cfg.servers;
|
|
}
|
|
];
|
|
}
|
|
];
|
|
};
|
|
};
|
|
}
|