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
|
@ -24,6 +24,26 @@ in {
|
|||
type = types.str;
|
||||
};
|
||||
};
|
||||
|
||||
ip = mkOption {
|
||||
type = types.str;
|
||||
default = cfg.host.ip;
|
||||
};
|
||||
|
||||
port = mkOption {
|
||||
type = types.port;
|
||||
default = port;
|
||||
};
|
||||
|
||||
datasource = {
|
||||
name = mkOption {
|
||||
type = types.str;
|
||||
};
|
||||
|
||||
url = mkOption {
|
||||
type = types.str;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
|
@ -44,6 +64,18 @@ in {
|
|||
domain = "${name}.skynet.ie";
|
||||
port = port;
|
||||
addr = cfg.host.ip;
|
||||
|
||||
provision = {
|
||||
enable = true;
|
||||
datasources.settings.datasources = [
|
||||
{
|
||||
name = cfg.datasource.name;
|
||||
type = "Prometheus";
|
||||
url = cfg.datasource.url;
|
||||
isDefault = true;
|
||||
}
|
||||
];
|
||||
};
|
||||
};
|
||||
|
||||
services.nginx.virtualHosts = {
|
||||
|
|
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