chore(monitoring): nf-fmt-nix

This commit is contained in:
arcnmx 2024-05-30 14:10:18 -07:00
parent 6fb140c7e6
commit a0a7df1b0e
6 changed files with 164 additions and 141 deletions

View file

@ -11,18 +11,24 @@
nodeExporterSystems =
filter (
system:
system.config.access.online.enable &&
system.config.exports.prometheus.exporter.services != [ ]
system.config.access.online.enable
&& system.config.exports.prometheus.exporter.services != []
)
(attrValues systems);
mkPortTarget = { system, service, portName }: let
mkPortTarget = {
system,
service,
portName,
}: let
port = service.ports.${portName};
in "${access.getAddressFor system.config.name "lan"}:${toString port.port}";
mkServiceConfig = system: serviceName: let
service = system.config.exports.services.${serviceName};
targets = map (portName: mkPortTarget {
inherit system service portName;
}) service.prometheus.exporter.ports;
targets = map (portName:
mkPortTarget {
inherit system service portName;
})
service.prometheus.exporter.ports;
in {
job_name = "${system.config.name}-${service.id}";
static_configs = [

View file

@ -7,8 +7,9 @@
inherit (lib.attrsets) attrValues;
inherit (lib.lists) concatMap toList;
allExporters = let
exporters = removeAttrs config.services.prometheus.exporters [ "unifi-poller" ];
in concatMap toList (attrValues exporters);
exporters = removeAttrs config.services.prometheus.exporters ["unifi-poller"];
in
concatMap toList (attrValues exporters);
in {
config = {
services.prometheus.exporters = {
@ -57,8 +58,11 @@ in {
}
];
};
networking.firewall.interfaces.lan.allowedTCPPorts = map (exporter:
mkIf (exporter.enable && !exporter.openFirewall) 999
) allExporters;
networking.firewall.interfaces.lan.allowedTCPPorts =
map (
exporter:
mkIf (exporter.enable && !exporter.openFirewall) exporter.port
)
allExporters;
};
}