1 { config, lib, pkgs, options, ... }:
4 cfg = config.services.prometheus.exporters.junos-czerwonk;
13 configFile = if cfg.configuration != null then configurationFile else (escapeShellArg cfg.configurationFile);
15 configurationFile = pkgs.writeText "prometheus-junos-czerwonk-exporter.conf" (builtins.toJSON (cfg.configuration));
20 environmentFile = mkOption {
21 type = types.nullOr types.str;
24 File containing env-vars to be substituted into the exporter's config.
27 configurationFile = mkOption {
28 type = types.nullOr types.path;
31 Specify the JunOS exporter configuration file to use.
34 configuration = mkOption {
35 type = types.nullOr types.attrs;
38 JunOS exporter configuration as nix attribute set. Mutually exclusive with the `configurationFile` option.
44 key_file = "/path/to/key";
49 telemetryPath = mkOption {
53 Path under which to expose metrics.
60 EnvironmentFile = mkIf (cfg.environmentFile != null) [ cfg.environmentFile ];
61 RuntimeDirectory = "prometheus-junos-czerwonk-exporter";
63 "${pkgs.writeShellScript "subst-secrets-junos-czerwonk-exporter" ''
65 ${pkgs.envsubst}/bin/envsubst -i ${configFile} -o ''${RUNTIME_DIRECTORY}/junos-exporter.json
69 ${pkgs.prometheus-junos-czerwonk-exporter}/bin/junos_exporter \
70 -web.listen-address ${cfg.listenAddress}:${toString cfg.port} \
71 -web.telemetry-path ${cfg.telemetryPath} \
72 -config.file ''${RUNTIME_DIRECTORY}/junos-exporter.json \
73 ${concatStringsSep " \\\n " cfg.extraFlags}