2024-07-26 23:52:21 +00:00
|
|
|
{ config, lib, ... }:
|
|
|
|
let
|
2024-06-09 18:04:14 +00:00
|
|
|
cfg = config.selfprivacy.modules.monitoring;
|
2024-07-26 23:52:21 +00:00
|
|
|
in
|
|
|
|
{
|
2024-06-09 18:04:14 +00:00
|
|
|
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-07-26 22:17:57 +00:00
|
|
|
services.cadvisor = {
|
|
|
|
enable = true;
|
|
|
|
port = 9003;
|
|
|
|
listenAddress = "127.0.0.1";
|
2024-07-26 23:00:39 +00:00
|
|
|
extraOptions = [ "--enable_metrics=cpu,memory,diskIO" ];
|
2024-07-26 22:17:57 +00:00
|
|
|
};
|
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 22:17:57 +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
|
|
|
};
|
|
|
|
};
|
|
|
|
scrapeConfigs = [
|
|
|
|
{
|
|
|
|
job_name = "node-exporter";
|
|
|
|
static_configs = [{
|
|
|
|
targets = [ "127.0.0.1:9002" ];
|
|
|
|
}];
|
|
|
|
}
|
2024-07-26 16:31:03 +00:00
|
|
|
{
|
2024-07-26 22:17:57 +00:00
|
|
|
job_name = "cadvisor";
|
2024-07-26 16:31:03 +00:00
|
|
|
static_configs = [{
|
|
|
|
targets = [ "127.0.0.1:9003" ];
|
|
|
|
}];
|
|
|
|
}
|
2024-06-09 18:04:14 +00:00
|
|
|
];
|
|
|
|
};
|
2024-07-26 23:52:21 +00:00
|
|
|
systemd = {
|
|
|
|
services = {
|
|
|
|
prometheus.serviceConfig.Slice = "monitoring.slice";
|
|
|
|
prometheus-node-exporter.serviceConfig.Slice = "monitoring.slice";
|
|
|
|
cadvisor.serviceConfig.Slice = "monitoring.slice";
|
|
|
|
};
|
|
|
|
slices.monitoring = {
|
|
|
|
description = "Monitoring service slice";
|
|
|
|
};
|
|
|
|
};
|
2024-06-09 18:04:14 +00:00
|
|
|
};
|
2024-07-17 17:45:23 +00:00
|
|
|
}
|