2024-06-09 18:04:14 +00:00
|
|
|
{config, lib, ...}: let
|
|
|
|
cfg = config.selfprivacy.modules.monitoring;
|
|
|
|
in {
|
|
|
|
options.selfprivacy.modules.monitoring = {
|
|
|
|
enable = lib.mkOption {
|
|
|
|
default = false;
|
|
|
|
type = lib.types.bool;
|
|
|
|
};
|
2024-07-17 17:45:23 +00:00
|
|
|
location = lib.mkOption {
|
|
|
|
type = lib.types.str;
|
|
|
|
};
|
2024-06-09 18:04:14 +00:00
|
|
|
};
|
|
|
|
config = lib.mkIf cfg.enable {
|
2024-07-17 17:45:23 +00:00
|
|
|
fileSystems = lib.mkIf config.selfprivacy.useBinds {
|
|
|
|
"/var/lib/prometheus2" = {
|
|
|
|
device = "/volumes/${cfg.location}/prometheus";
|
|
|
|
options = [
|
|
|
|
"bind"
|
|
|
|
"x-systemd.required-by=prometheus.service"
|
|
|
|
"x-systemd.before=prometheus.service"
|
|
|
|
];
|
|
|
|
};
|
|
|
|
};
|
2024-06-09 18:04:14 +00:00
|
|
|
services.prometheus = {
|
|
|
|
enable = true;
|
|
|
|
port = 9001;
|
2024-06-17 18:42:49 +00:00
|
|
|
listenAddress = "127.0.0.1";
|
2024-06-09 18:04:14 +00:00
|
|
|
exporters = {
|
|
|
|
node = {
|
|
|
|
enable = true;
|
2024-07-26 16:28:25 +00:00
|
|
|
enabledCollectors = [ "systemd" ];
|
2024-06-09 18:04:14 +00:00
|
|
|
port = 9002;
|
2024-06-18 18:30:02 +00:00
|
|
|
listenAddress = "127.0.0.1";
|
2024-06-09 18:04:14 +00:00
|
|
|
};
|
2024-07-26 16:31:03 +00:00
|
|
|
systemd = {
|
|
|
|
enable = true;
|
|
|
|
port = 9003;
|
|
|
|
listenAddress = "127.0.0.1";
|
|
|
|
};
|
2024-06-09 18:04:14 +00:00
|
|
|
};
|
|
|
|
scrapeConfigs = [
|
|
|
|
{
|
|
|
|
job_name = "node-exporter";
|
|
|
|
static_configs = [{
|
|
|
|
targets = [ "127.0.0.1:9002" ];
|
|
|
|
}];
|
|
|
|
}
|
2024-07-26 16:31:03 +00:00
|
|
|
{
|
|
|
|
job_name = "systemd-exporter";
|
|
|
|
static_configs = [{
|
|
|
|
targets = [ "127.0.0.1:9003" ];
|
|
|
|
}];
|
|
|
|
}
|
2024-06-09 18:04:14 +00:00
|
|
|
];
|
|
|
|
};
|
|
|
|
};
|
2024-07-17 17:45:23 +00:00
|
|
|
}
|