10 cfg = config.services.prometheus.exporters.junos-czerwonk;
20 if cfg.configuration != null then configurationFile else (escapeShellArg cfg.configurationFile);
22 configurationFile = pkgs.writeText "prometheus-junos-czerwonk-exporter.conf" (
23 builtins.toJSON (cfg.configuration)
29 environmentFile = mkOption {
30 type = types.nullOr types.str;
33 File containing env-vars to be substituted into the exporter's config.
36 configurationFile = mkOption {
37 type = types.nullOr types.path;
40 Specify the JunOS exporter configuration file to use.
43 configuration = mkOption {
44 type = types.nullOr types.attrs;
47 JunOS exporter configuration as nix attribute set. Mutually exclusive with the `configurationFile` option.
53 key_file = "/path/to/key";
58 telemetryPath = mkOption {
62 Path under which to expose metrics.
69 EnvironmentFile = mkIf (cfg.environmentFile != null) [ cfg.environmentFile ];
70 RuntimeDirectory = "prometheus-junos-czerwonk-exporter";
72 "${pkgs.writeShellScript "subst-secrets-junos-czerwonk-exporter" ''
74 ${pkgs.envsubst}/bin/envsubst -i ${configFile} -o ''${RUNTIME_DIRECTORY}/junos-exporter.json
78 ${pkgs.prometheus-junos-czerwonk-exporter}/bin/junos_exporter \
79 -web.listen-address ${cfg.listenAddress}:${toString cfg.port} \
80 -web.telemetry-path ${cfg.telemetryPath} \
81 -config.file ''${RUNTIME_DIRECTORY}/junos-exporter.json \
82 ${concatStringsSep " \\\n " cfg.extraFlags}