selfprivacy-nixos-config/sp-modules/monitoring/module.nix

72 lines
1.7 KiB
Nix
Raw Normal View History

2024-07-26 23:52:21 +00:00
{ config, lib, ... }:
let
cfg = config.selfprivacy.modules.monitoring;
2024-07-26 23:52:21 +00:00
in
{
options.selfprivacy.modules.monitoring = {
enable = lib.mkOption {
default = false;
type = lib.types.bool;
};
location = lib.mkOption {
type = lib.types.str;
};
};
config = lib.mkIf cfg.enable {
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-29 14:39:14 +00:00
security.auditd.enable = true;
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
};
services.prometheus = {
enable = true;
port = 9001;
listenAddress = "127.0.0.1";
exporters = {
node = {
enable = true;
2024-07-26 22:17:57 +00:00
enabledCollectors = [ "systemd" ];
port = 9002;
listenAddress = "127.0.0.1";
};
};
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-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";
};
};
};
}