Merge pull request #98746 from mayflower/postfix-exporter-group

prometheus postfix exporter: misc
This commit is contained in:
WilliButz 2020-09-27 22:37:38 +02:00 committed by GitHub
commit e736a990c1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 23 additions and 6 deletions

View File

@ -229,6 +229,8 @@ in
})] ++ [(mkIf config.services.nginx.enable { })] ++ [(mkIf config.services.nginx.enable {
systemd.services.prometheus-nginx-exporter.after = [ "nginx.service" ]; systemd.services.prometheus-nginx-exporter.after = [ "nginx.service" ];
systemd.services.prometheus-nginx-exporter.requires = [ "nginx.service" ]; systemd.services.prometheus-nginx-exporter.requires = [ "nginx.service" ];
})] ++ [(mkIf config.services.postfix.enable {
services.prometheus.exporters.postfix.group = mkDefault config.services.postfix.setgidGroup;
})] ++ (mapAttrsToList (name: conf: })] ++ (mapAttrsToList (name: conf:
mkExporterConf { mkExporterConf {
inherit name; inherit name;

View File

@ -8,6 +8,15 @@ in
{ {
port = 9154; port = 9154;
extraOpts = { extraOpts = {
group = mkOption {
type = types.str;
description = ''
Group under which the postfix exporter shall be run.
It should match the group that is allowed to access the
<literal>showq</literal> socket in the <literal>queue/public/</literal> directory.
Defaults to <literal>services.postfix.setgidGroup</literal> when postfix is enabled.
'';
};
telemetryPath = mkOption { telemetryPath = mkOption {
type = types.str; type = types.str;
default = "/metrics"; default = "/metrics";
@ -26,16 +35,20 @@ in
}; };
showqPath = mkOption { showqPath = mkOption {
type = types.path; type = types.path;
default = "/var/spool/postfix/public/showq"; default = "/var/lib/postfix/queue/public/showq";
example = "/var/lib/postfix/queue/public/showq"; example = "/var/spool/postfix/public/showq";
description = '' description = ''
Path where Postfix places it's showq socket. Path where Postfix places its showq socket.
''; '';
}; };
systemd = { systemd = {
enable = mkEnableOption '' enable = mkOption {
reading metrics from the systemd-journal instead of from a logfile type = types.bool;
default = true;
description = ''
Whether to enable reading metrics from the systemd journal instead of from a logfile
''; '';
};
unit = mkOption { unit = mkOption {
type = types.str; type = types.str;
default = "postfix.service"; default = "postfix.service";

View File

@ -466,10 +466,12 @@ let
}; };
exporterTest = '' exporterTest = ''
wait_for_unit("prometheus-postfix-exporter.service") wait_for_unit("prometheus-postfix-exporter.service")
wait_for_file("/var/lib/postfix/queue/public/showq")
wait_for_open_port(9154) wait_for_open_port(9154)
succeed( succeed(
"curl -sSf http://localhost:9154/metrics | grep -q 'postfix_smtpd_connects_total 0'" "curl -sSf http://localhost:9154/metrics | grep -q 'postfix_smtpd_connects_total 0'"
) )
succeed("curl -sSf http://localhost:9154/metrics | grep -q 'postfix_up{.*} 1'")
''; '';
}; };