mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-11-18 22:56:00 +01:00
Fixes issues described in #208242 for this part of the nixpkgs tree. There are no behavioral changes in this, it only adjusts the code so that it is easier to understand.
37 lines
1.1 KiB
Nix
37 lines
1.1 KiB
Nix
{ config, lib, pkgs, options, ... }:
|
|
|
|
let
|
|
cfg = config.services.prometheus.exporters.unpoller;
|
|
inherit (lib) mkEnableOption generators;
|
|
|
|
configFile = pkgs.writeText "prometheus-unpoller-exporter.json" (generators.toJSON {} {
|
|
poller = { inherit (cfg.log) debug quiet; };
|
|
unifi = { inherit (cfg) controllers; };
|
|
influxdb.disable = true;
|
|
datadog.disable = true; # workaround for https://github.com/unpoller/unpoller/issues/442
|
|
prometheus = {
|
|
http_listen = "${cfg.listenAddress}:${toString cfg.port}";
|
|
report_errors = cfg.log.prometheusErrors;
|
|
};
|
|
inherit (cfg) loki;
|
|
});
|
|
|
|
in {
|
|
port = 9130;
|
|
|
|
extraOpts = {
|
|
inherit (options.services.unpoller.unifi) controllers;
|
|
inherit (options.services.unpoller) loki;
|
|
log = {
|
|
debug = mkEnableOption "debug logging including line numbers, high resolution timestamps, per-device logs";
|
|
quiet = mkEnableOption "startup and error logs only";
|
|
prometheusErrors = mkEnableOption "emitting errors to prometheus";
|
|
};
|
|
};
|
|
|
|
serviceOpts.serviceConfig = {
|
|
ExecStart = "${pkgs.unpoller}/bin/unpoller --config ${configFile}";
|
|
DynamicUser = false;
|
|
};
|
|
}
|