1 { config, lib, pkgs, options, ... }:
4 cfg = config.services.prometheus.exporters.dovecot;
15 telemetryPath = mkOption {
19 Path under which to expose metrics.
22 socketPath = mkOption {
24 default = "/var/run/dovecot/stats";
25 example = "/var/run/dovecot2/old-stats";
27 Path under which the stats socket is placed.
28 The user/group under which the exporter runs,
29 should be able to access the socket in order
30 to scrape the metrics successfully.
32 Please keep in mind that the stats module has changed in
33 [Dovecot 2.3+](https://wiki2.dovecot.org/Upgrading/2.3) which
34 is not [compatible with this exporter](https://github.com/kumina/dovecot_exporter/issues/8).
36 The following extra config has to be passed to Dovecot to ensure that recent versions
37 work with this exporter:
40 services.prometheus.exporters.dovecot.enable = true;
41 services.prometheus.exporters.dovecot.socketPath = "/var/run/dovecot2/old-stats";
42 services.dovecot2.mailPlugins.globally.enable = [ "old_stats" ];
43 services.dovecot2.extraConfig = '''
45 unix_listener old-stats {
46 user = dovecot-exporter
47 group = dovecot-exporter
50 fifo_listener old-stats-mail {
55 fifo_listener old-stats-user {
62 old_stats_refresh = 30 secs
63 old_stats_track_cmds = yes
71 type = types.listOf types.str;
73 example = [ "user" "global" ];
75 Stats scopes to query.
83 ${pkgs.prometheus-dovecot-exporter}/bin/dovecot_exporter \
84 --web.listen-address ${cfg.listenAddress}:${toString cfg.port} \
85 --web.telemetry-path ${cfg.telemetryPath} \
86 --dovecot.socket-path ${escapeShellArg cfg.socketPath} \
87 --dovecot.scopes ${concatStringsSep "," cfg.scopes} \
88 ${concatStringsSep " \\\n " cfg.extraFlags}
90 RestrictAddressFamilies = [
91 # Need AF_UNIX to collect data