1{ 2 config, 3 lib, 4 pkgs, 5 options, 6 ... 7}: 8 9let 10 cfg = config.services.prometheus.exporters.unpoller; 11 inherit (lib) mkEnableOption generators; 12 13 configFile = pkgs.writeText "prometheus-unpoller-exporter.json" ( 14 generators.toJSON { } { 15 poller = { inherit (cfg.log) debug quiet; }; 16 unifi = { inherit (cfg) controllers; }; 17 influxdb.disable = true; 18 datadog.disable = true; # workaround for https://github.com/unpoller/unpoller/issues/442 19 prometheus = { 20 http_listen = "${cfg.listenAddress}:${toString cfg.port}"; 21 report_errors = cfg.log.prometheusErrors; 22 }; 23 inherit (cfg) loki; 24 } 25 ); 26 27in 28{ 29 port = 9130; 30 31 extraOpts = { 32 inherit (options.services.unpoller.unifi) controllers; 33 inherit (options.services.unpoller) loki; 34 log = { 35 debug = mkEnableOption "debug logging including line numbers, high resolution timestamps, per-device logs"; 36 quiet = mkEnableOption "startup and error logs only"; 37 prometheusErrors = mkEnableOption "emitting errors to prometheus"; 38 }; 39 }; 40 41 serviceOpts.serviceConfig = { 42 ExecStart = "${pkgs.unpoller}/bin/unpoller --config ${configFile}"; 43 DynamicUser = false; 44 }; 45}