1{ config, lib, pkgs }: 2 3with lib; 4 5let 6 cfg = config.services.prometheus.exporters.dovecot; 7in 8{ 9 port = 9166; 10 extraOpts = { 11 telemetryPath = mkOption { 12 type = types.str; 13 default = "/metrics"; 14 description = '' 15 Path under which to expose metrics. 16 ''; 17 }; 18 socketPath = mkOption { 19 type = types.path; 20 default = "/var/run/dovecot/stats"; 21 example = "/var/run/dovecot2/stats"; 22 description = '' 23 Path under which the stats socket is placed. 24 The user/group under which the exporter runs, 25 should be able to access the socket in order 26 to scrape the metrics successfully. 27 ''; 28 }; 29 scopes = mkOption { 30 type = types.listOf types.str; 31 default = [ "user" ]; 32 example = [ "user" "global" ]; 33 description = '' 34 Stats scopes to query. 35 ''; 36 }; 37 }; 38 serviceOpts = { 39 serviceConfig = { 40 ExecStart = '' 41 ${pkgs.prometheus-dovecot-exporter}/bin/dovecot_exporter \ 42 --web.listen-address ${cfg.listenAddress}:${toString cfg.port} \ 43 --web.telemetry-path ${cfg.telemetryPath} \ 44 --dovecot.socket-path ${cfg.socketPath} \ 45 --dovecot.scopes ${concatStringsSep "," cfg.scopes} \ 46 ${concatStringsSep " \\\n " cfg.extraFlags} 47 ''; 48 }; 49 }; 50}