diff --git a/nixos/modules/monitoring/exporters/tahoe.nix b/nixos/modules/monitoring/exporters/tahoe.nix index 0f24bb6c099725242647e4fa23fba20da644811d..b04d69dbf56cc96b81c841e41011c691b973ead7 100644 --- a/nixos/modules/monitoring/exporters/tahoe.nix +++ b/nixos/modules/monitoring/exporters/tahoe.nix @@ -1,7 +1,7 @@ # Tahoe Prometheus metrics collector # -# Scope: Retrieves OpenMetrics from Tahoe and puts them -# where textfile collector can find them. +# Scope: Retrieve metrics from Tahoe and put them where Prometheus' +# node-exporter's textfile collector can find them. # # Usage: Import this to every server running Tahoe. # @@ -55,14 +55,17 @@ in { description = "Tahoe metrics gathering service"; after = [ "tahoe.storage.service" ]; startAt = cfg.interval; - path = [ pkgs.curl ]; + path = [ pkgs.coreutils pkgs.findutils pkgs.curl ]; restartIfChanged = false; # Save to a temp file and then move atomically so the # textfile collector won't read a partial file. # See https://github.com/prometheus/node_exporter#textfile-collector script = '' - curl --silent --show-error --fail-with-body --output "${cfg.outFile}.tmp" "${cfg.scrapeEndpoint}" + NUM_CORRUPTION_ADVISORIES=$(find /storage/corruption-advisories/ -type f | wc -l) + echo "tahoe_corruption_advisories_total $NUM_CORRUPTION_ADVISORIES" > "${cfg.outFile}.tmp" + + curl --silent --show-error --fail-with-body "${cfg.scrapeEndpoint}" >> "${cfg.outFile}.tmp" mv "${cfg.outFile}.tmp" "${cfg.outFile}" ''; };