fix(monitoring): exporter firewall rules

This commit is contained in:
arcnmx 2024-05-30 14:02:03 -07:00
parent 4d1a542384
commit 6fb140c7e6

View file

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