Initial prometheus config
Also did provision config for grafana, could be done directly but went through skynet.grafana config
This commit is contained in:
parent
50abdb90ab
commit
183f5a0e7d
4 changed files with 137 additions and 0 deletions
67
applications/prometheus.nix
Normal file
67
applications/prometheus.nix
Normal file
|
@ -0,0 +1,67 @@
|
|||
{
|
||||
lib,
|
||||
config,
|
||||
...
|
||||
}:
|
||||
with lib; let
|
||||
name = "prometheus";
|
||||
cfg = config.services.skynet."${name}";
|
||||
in {
|
||||
imports = [];
|
||||
|
||||
options.services.skynet."${name}" = {
|
||||
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;
|
||||
};
|
||||
|
||||
#list of servers passed in for monitoring
|
||||
servers = mkOption {
|
||||
type = types.listOf types.str;
|
||||
};
|
||||
};
|
||||
|
||||
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:9002") cfg.servers;
|
||||
}
|
||||
];
|
||||
}
|
||||
];
|
||||
};
|
||||
};
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue