mirror of
https://github.com/dump-dvb/nix-config.git
synced 2024-06-17 21:35:38 +02:00
refactor monitoring module to allow kicking out inactive systems
This commit is contained in:
parent
84582cdb63
commit
f29b63f709
|
@ -7,6 +7,6 @@
|
||||||
./json.nix
|
./json.nix
|
||||||
./net.nix
|
./net.nix
|
||||||
./wg.nix
|
./wg.nix
|
||||||
./node-exporter.nix
|
./monitoring.nix
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
45
modules/TLMS/monitoring.nix
Normal file
45
modules/TLMS/monitoring.nix
Normal file
|
@ -0,0 +1,45 @@
|
||||||
|
{ lib, config, ... }:
|
||||||
|
let
|
||||||
|
cfg = config.deployment-TLMS.monitoring;
|
||||||
|
in
|
||||||
|
{
|
||||||
|
options.deployment-TLMS.monitoring = with lib; {
|
||||||
|
enable = mkOption {
|
||||||
|
type = types.bool;
|
||||||
|
default = true;
|
||||||
|
description = ''
|
||||||
|
Whether to enable TLMS default prometheus exporter and log collection
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
monitoring.node-exporter = with lib; {
|
||||||
|
port = mkOption {
|
||||||
|
type = types.port;
|
||||||
|
default = 8119;
|
||||||
|
description = ''
|
||||||
|
Default port for prometheus node exporter to listen to
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
config =
|
||||||
|
let
|
||||||
|
wg-addr-pred = !isNull config.deployment-TLMS.net.wg.addr4;
|
||||||
|
check-wg = enabled:
|
||||||
|
lib.assertMsg (enabled && wg-addr-pred)
|
||||||
|
''For monitoring to be working the system must be in wireguard. See config.deplayment-TLMS.net.wg'';
|
||||||
|
in
|
||||||
|
lib.mkIf (check-wg cfg.enable) {
|
||||||
|
# prometheus node exporter
|
||||||
|
services.prometheus.exporters = {
|
||||||
|
node = {
|
||||||
|
enable = true;
|
||||||
|
port = 8119;
|
||||||
|
listenAddress = config.deployment-TLMS.net.wg.addr4;
|
||||||
|
enabledCollectors = [
|
||||||
|
"systemd"
|
||||||
|
];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
|
@ -1,14 +0,0 @@
|
||||||
{ config, ... }:
|
|
||||||
{
|
|
||||||
# metrics exporter
|
|
||||||
services.prometheus.exporters = {
|
|
||||||
node = {
|
|
||||||
enable = true;
|
|
||||||
port = 8119;
|
|
||||||
listenAddress = config.deployment-TLMS.net.wg.addr4;
|
|
||||||
enabledCollectors = [
|
|
||||||
"systemd"
|
|
||||||
];
|
|
||||||
};
|
|
||||||
};
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user