Merge pull request #125684 from NixOS/backport-125483-to-release-21.05
[Backport release-21.05] nixos/prometheus-exporters: improve docs & fix rspamd exporter
This commit is contained in:
commit
aa57635767
|
@ -35,13 +35,28 @@ in
|
||||||
{
|
{
|
||||||
<xref linkend="opt-services.prometheus.exporters.dovecot.enable" /> = true;
|
<xref linkend="opt-services.prometheus.exporters.dovecot.enable" /> = true;
|
||||||
<xref linkend="opt-services.prometheus.exporters.dovecot.socketPath" /> = "/var/run/dovecot2/old-stats";
|
<xref linkend="opt-services.prometheus.exporters.dovecot.socketPath" /> = "/var/run/dovecot2/old-stats";
|
||||||
|
<xref linkend="opt-services.dovecot2.mailPlugins.globally.enable" /> = [ "old_stats" ];
|
||||||
<xref linkend="opt-services.dovecot2.extraConfig" /> = '''
|
<xref linkend="opt-services.dovecot2.extraConfig" /> = '''
|
||||||
mail_plugins = $mail_plugins old_stats
|
|
||||||
service old-stats {
|
service old-stats {
|
||||||
unix_listener old-stats {
|
unix_listener old-stats {
|
||||||
user = dovecot-exporter
|
user = dovecot-exporter
|
||||||
group = 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
|
||||||
}
|
}
|
||||||
''';
|
''';
|
||||||
}
|
}
|
||||||
|
|
|
@ -112,6 +112,24 @@ let
|
||||||
'';
|
'';
|
||||||
description = ''
|
description = ''
|
||||||
List of servers that should be probed.
|
List of servers that should be probed.
|
||||||
|
|
||||||
|
<emphasis>Note:</emphasis> if your mailserver has <citerefentry>
|
||||||
|
<refentrytitle>rspamd</refentrytitle><manvolnum>8</manvolnum></citerefentry> 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:
|
||||||
|
<programlisting>
|
||||||
|
{
|
||||||
|
<link linkend="opt-services.rspamd.locals._name_.text">services.rspamd.locals."multimap.conf".text</link> = '''
|
||||||
|
ALLOWLIST_PROMETHEUS {
|
||||||
|
filter = "email:domain:tld";
|
||||||
|
type = "from";
|
||||||
|
map = "''${pkgs.writeText "allowmap" "domain.tld"}";
|
||||||
|
score = -100.0;
|
||||||
|
}
|
||||||
|
''';
|
||||||
|
}
|
||||||
|
</programlisting>
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
@ -5,21 +5,19 @@ with lib;
|
||||||
let
|
let
|
||||||
cfg = config.services.prometheus.exporters.rspamd;
|
cfg = config.services.prometheus.exporters.rspamd;
|
||||||
|
|
||||||
prettyJSON = conf:
|
mkFile = conf:
|
||||||
pkgs.runCommand "rspamd-exporter-config.yml" { } ''
|
pkgs.writeText "rspamd-exporter-config.yml" (builtins.toJSON conf);
|
||||||
echo '${builtins.toJSON conf}' | ${pkgs.buildPackages.jq}/bin/jq '.' > $out
|
|
||||||
'';
|
|
||||||
|
|
||||||
generateConfig = extraLabels: {
|
generateConfig = extraLabels: {
|
||||||
metrics = (map (path: {
|
metrics = (map (path: {
|
||||||
name = "rspamd_${replaceStrings [ "." " " ] [ "_" "_" ] path}";
|
name = "rspamd_${replaceStrings [ "[" "." " " "]" "\\" "'" ] [ "_" "_" "_" "" "" "" ] path}";
|
||||||
path = "{ .${path} }";
|
path = "{ .${path} }";
|
||||||
labels = extraLabels;
|
labels = extraLabels;
|
||||||
}) [
|
}) [
|
||||||
"actions.'add header'"
|
"actions['add\\ header']"
|
||||||
"actions.'no action'"
|
"actions['no\\ action']"
|
||||||
"actions.'rewrite subject'"
|
"actions['rewrite\\ subject']"
|
||||||
"actions.'soft reject'"
|
"actions['soft\\ reject']"
|
||||||
"actions.greylist"
|
"actions.greylist"
|
||||||
"actions.reject"
|
"actions.reject"
|
||||||
"bytes_allocated"
|
"bytes_allocated"
|
||||||
|
@ -40,18 +38,18 @@ let
|
||||||
]) ++ [{
|
]) ++ [{
|
||||||
name = "rspamd_statfiles";
|
name = "rspamd_statfiles";
|
||||||
type = "object";
|
type = "object";
|
||||||
path = "$.statfiles[*]";
|
path = "{.statfiles[*]}";
|
||||||
labels = recursiveUpdate {
|
labels = recursiveUpdate {
|
||||||
symbol = "$.symbol";
|
symbol = "{.symbol}";
|
||||||
type = "$.type";
|
type = "{.type}";
|
||||||
} extraLabels;
|
} extraLabels;
|
||||||
values = {
|
values = {
|
||||||
revision = "$.revision";
|
revision = "{.revision}";
|
||||||
size = "$.size";
|
size = "{.size}";
|
||||||
total = "$.total";
|
total = "{.total}";
|
||||||
used = "$.used";
|
used = "{.used}";
|
||||||
languages = "$.languages";
|
languages = "{.languages}";
|
||||||
users = "$.users";
|
users = "{.users}";
|
||||||
};
|
};
|
||||||
}];
|
}];
|
||||||
};
|
};
|
||||||
|
@ -76,7 +74,7 @@ in
|
||||||
};
|
};
|
||||||
serviceOpts.serviceConfig.ExecStart = ''
|
serviceOpts.serviceConfig.ExecStart = ''
|
||||||
${pkgs.prometheus-json-exporter}/bin/json_exporter \
|
${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}" \
|
--web.listen-address "${cfg.listenAddress}:${toString cfg.port}" \
|
||||||
${concatStringsSep " \\\n " cfg.extraFlags}
|
${concatStringsSep " \\\n " cfg.extraFlags}
|
||||||
'';
|
'';
|
||||||
|
|
Loading…
Reference in New Issue