9 cfg = config.services.prometheus.exporters.postfix;
22 package = lib.mkPackageOption pkgs "prometheus-postfix-exporter" { };
26 Group under which the postfix exporter shall be run.
27 It should match the group that is allowed to access the
28 `showq` socket in the `queue/public/` directory.
29 Defaults to `services.postfix.setgidGroup` when postfix is enabled.
32 telemetryPath = mkOption {
36 Path under which to expose metrics.
39 logfilePath = mkOption {
41 default = "/var/log/postfix_exporter_input.log";
42 example = "/var/log/mail.log";
44 Path where Postfix writes log entries.
45 This file will be truncated by this exporter!
48 showqPath = mkOption {
50 default = "/var/lib/postfix/queue/public/showq";
51 example = "/var/spool/postfix/public/showq";
53 Path where Postfix places its showq socket.
61 Whether to enable reading metrics from the systemd journal instead of from a logfile
66 default = "postfix.service";
68 Name of the postfix systemd unit.
72 type = types.nullOr types.str;
75 Name of the postfix systemd slice.
76 This overrides the {option}`systemd.unit`.
79 journalPath = mkOption {
80 type = types.nullOr types.path;
83 Path to the systemd journal.
89 after = mkIf cfg.systemd.enable [ cfg.systemd.unit ];
92 # By default, each prometheus exporter only gets AF_INET & AF_INET6,
93 # but AF_UNIX is needed to read from the `showq`-socket.
94 RestrictAddressFamilies = [ "AF_UNIX" ];
95 SupplementaryGroups = mkIf cfg.systemd.enable [ "systemd-journal" ];
97 ${lib.getExe cfg.package} \
98 --web.listen-address ${cfg.listenAddress}:${toString cfg.port} \
99 --web.telemetry-path ${cfg.telemetryPath} \
100 --postfix.showq_path ${escapeShellArg cfg.showqPath} \
101 ${concatStringsSep " \\\n " (
103 ++ optional cfg.systemd.enable "--systemd.enable"
104 ++ optional cfg.systemd.enable (
105 if cfg.systemd.slice != null then
106 "--systemd.slice ${cfg.systemd.slice}"
108 "--systemd.unit ${cfg.systemd.unit}"
111 cfg.systemd.enable && (cfg.systemd.journalPath != null)
112 ) "--systemd.journal_path ${escapeShellArg cfg.systemd.journalPath}"
113 ++ optional (!cfg.systemd.enable) "--postfix.logfile_path ${escapeShellArg cfg.logfilePath}"