Merge pull request #146653 from DarkDNA/nixos/fix-systemd-exporter/extraFlags

nixos/prometheus/systemd: Implement the extraFlags config option.
This commit is contained in:
pennae 2022-03-09 16:12:32 +00:00 committed by GitHub
commit 06c57317c2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 1 deletions

View file

@ -11,7 +11,7 @@ in {
serviceConfig = {
ExecStart = ''
${pkgs.prometheus-systemd-exporter}/bin/systemd_exporter \
--web.listen-address ${cfg.listenAddress}:${toString cfg.port}
--web.listen-address ${cfg.listenAddress}:${toString cfg.port} ${concatStringsSep " " cfg.extraFlags}
'';
RestrictAddressFamilies = [
# Need AF_UNIX to collect data

View file

@ -1156,6 +1156,10 @@ let
systemd = {
exporterConfig = {
enable = true;
extraFlags = [
"--collector.enable-restart-count"
];
};
metricProvider = { };
exporterTest = ''
@ -1166,6 +1170,11 @@ let
'systemd_unit_state{name="basic.target",state="active",type="target"} 1'
)
)
succeed(
"curl -sSf localhost:9558/metrics | grep '{}'".format(
'systemd_service_restart_total{state="prometheus-systemd-exporter.service"} 0'
)
)
'';
};