at 21.11-pre 989 B view raw
1{ config, lib, pkgs, options }: 2 3with lib; 4 5let 6 cfg = config.services.prometheus.exporters.unifi-poller; 7 8 configFile = pkgs.writeText "prometheus-unifi-poller-exporter.json" (generators.toJSON {} { 9 poller = { inherit (cfg.log) debug quiet; }; 10 unifi = { inherit (cfg) controllers; }; 11 influxdb.disable = true; 12 prometheus = { 13 http_listen = "${cfg.listenAddress}:${toString cfg.port}"; 14 report_errors = cfg.log.prometheusErrors; 15 }; 16 }); 17 18in { 19 port = 9130; 20 21 extraOpts = { 22 inherit (options.services.unifi-poller.unifi) controllers; 23 log = { 24 debug = mkEnableOption "debug logging including line numbers, high resolution timestamps, per-device logs."; 25 quiet = mkEnableOption "startup and error logs only."; 26 prometheusErrors = mkEnableOption "emitting errors to prometheus."; 27 }; 28 }; 29 30 serviceOpts.serviceConfig = { 31 ExecStart = "${pkgs.unifi-poller}/bin/unifi-poller --config ${configFile}"; 32 DynamicUser = false; 33 }; 34}