diff --git a/nixos/modules/services/monitoring/prometheus/exporters/dovecot.nix b/nixos/modules/services/monitoring/prometheus/exporters/dovecot.nix index aba3533e4395..472652fe8a7a 100644 --- a/nixos/modules/services/monitoring/prometheus/exporters/dovecot.nix +++ b/nixos/modules/services/monitoring/prometheus/exporters/dovecot.nix @@ -35,13 +35,28 @@ in { = true; = "/var/run/dovecot2/old-stats"; + = [ "old_stats" ]; = ''' - mail_plugins = $mail_plugins old_stats service old-stats { unix_listener old-stats { user = dovecot-exporter group = dovecot-exporter + mode = 0660 } + fifo_listener old-stats-mail { + mode = 0660 + user = dovecot + group = dovecot + } + fifo_listener old-stats-user { + mode = 0660 + user = dovecot + group = dovecot + } + } + plugin { + old_stats_refresh = 30 secs + old_stats_track_cmds = yes } '''; } diff --git a/nixos/modules/services/monitoring/prometheus/exporters/mail.nix b/nixos/modules/services/monitoring/prometheus/exporters/mail.nix index 18c5c4dd1623..7e196149fbb3 100644 --- a/nixos/modules/services/monitoring/prometheus/exporters/mail.nix +++ b/nixos/modules/services/monitoring/prometheus/exporters/mail.nix @@ -112,6 +112,24 @@ let ''; description = '' List of servers that should be probed. + + Note: if your mailserver has + rspamd8 configured, + it can happen that emails from this exporter are marked as spam. + + It's possible to work around the issue with a config like this: + + { + services.rspamd.locals."multimap.conf".text = ''' + ALLOWLIST_PROMETHEUS { + filter = "email:domain:tld"; + type = "from"; + map = "''${pkgs.writeText "allowmap" "domain.tld"}"; + score = -100.0; + } + '''; + } + ''; }; }; diff --git a/nixos/modules/services/monitoring/prometheus/exporters/rspamd.nix b/nixos/modules/services/monitoring/prometheus/exporters/rspamd.nix index d95e5ed9e83c..994670a376e7 100644 --- a/nixos/modules/services/monitoring/prometheus/exporters/rspamd.nix +++ b/nixos/modules/services/monitoring/prometheus/exporters/rspamd.nix @@ -5,21 +5,19 @@ with lib; let cfg = config.services.prometheus.exporters.rspamd; - prettyJSON = conf: - pkgs.runCommand "rspamd-exporter-config.yml" { } '' - echo '${builtins.toJSON conf}' | ${pkgs.buildPackages.jq}/bin/jq '.' > $out - ''; + mkFile = conf: + pkgs.writeText "rspamd-exporter-config.yml" (builtins.toJSON conf); generateConfig = extraLabels: { metrics = (map (path: { - name = "rspamd_${replaceStrings [ "." " " ] [ "_" "_" ] path}"; + name = "rspamd_${replaceStrings [ "[" "." " " "]" "\\" "'" ] [ "_" "_" "_" "" "" "" ] path}"; path = "{ .${path} }"; labels = extraLabels; }) [ - "actions.'add header'" - "actions.'no action'" - "actions.'rewrite subject'" - "actions.'soft reject'" + "actions['add\\ header']" + "actions['no\\ action']" + "actions['rewrite\\ subject']" + "actions['soft\\ reject']" "actions.greylist" "actions.reject" "bytes_allocated" @@ -40,18 +38,18 @@ let ]) ++ [{ name = "rspamd_statfiles"; type = "object"; - path = "$.statfiles[*]"; + path = "{.statfiles[*]}"; labels = recursiveUpdate { - symbol = "$.symbol"; - type = "$.type"; + symbol = "{.symbol}"; + type = "{.type}"; } extraLabels; values = { - revision = "$.revision"; - size = "$.size"; - total = "$.total"; - used = "$.used"; - languages = "$.languages"; - users = "$.users"; + revision = "{.revision}"; + size = "{.size}"; + total = "{.total}"; + used = "{.used}"; + languages = "{.languages}"; + users = "{.users}"; }; }]; }; @@ -76,7 +74,7 @@ in }; serviceOpts.serviceConfig.ExecStart = '' ${pkgs.prometheus-json-exporter}/bin/json_exporter \ - --config.file ${prettyJSON (generateConfig cfg.extraLabels)} \ + --config.file ${mkFile (generateConfig cfg.extraLabels)} \ --web.listen-address "${cfg.listenAddress}:${toString cfg.port}" \ ${concatStringsSep " \\\n " cfg.extraFlags} '';