Repository navigation
Description
What
Let opencloud storage-users revisions cleanup push metrics about its run, so that the runs from a cron job show up in Prometheus and Grafana next to the metrics of the server.
Why
The revision cleanup (#1419) cleans up a file when it gets a new version, and the server exports metrics for that (reva_revision_cleanup_*). Files that never change again are cleaned up by the command, typically from a nightly cron job, e.g. revisions cleanup --all --timeout 1h --shuffle. Right after a rollout, these runs free most of the space.
The command runs in a process of its own and ends when it's done, so it can't be scraped: what it deletes never reaches the server's counters, and the only traces of a run are its exit code, its log and its --json output. Admins can't see in their monitoring whether last night's run succeeded, stopped at --timeout, or how much it freed, nor alert when it hasn't run for days.
Prometheus documents this as the one valid use of the Pushgateway: "capturing the outcome of a service-level batch job".
Proposal
- Opt-in: a flag and an environment variable with the URL to push to (e.g.
--push-metrics <url>,STORAGE_USERS_REVISIONS_CLEANUP_PUSH_METRICS_URL), with optional basic auth or a bearer token, and TLS settings. Off by default. - Never fatal: a failed push is logged as a warning; it doesn't change the result or the exit code of the cleanup.
- The outcome of the last run, as gauges, in a registry of their own (not the process's default registry, which also holds the driver's queue gauges and the Go runtime metrics):
- revisions and bytes deleted, by
space_type(as the server's counters) - revisions that could not be deleted, files skipped
- the duration of the run
- the outcome: done, failed, or stopped by
--timeout - the time of the last run and of the last successful run, e.g. for an alert "no successful run for two days"
- revisions and bytes deleted, by
- Replaced by each run, under a grouping key of the job and the host (Pushgateway:
PUT), so that they don't add up with the server's counters. - Dry runs push nothing (or only with an explicit flag, to separate series).
Open questions
- Which push target?
- The Pushgateway is made for this, and needs no new dependency:
github.com/prometheus/client_golang/prometheus/pushis part of a module opencloud already uses. It is an extra component to run, though. - OTLP over HTTP goes straight into Prometheus 3 (
--web.enable-otlp-receiver), and into the OpenTelemetry Collector, Grafana Alloy or Mimir; opencloud already exports traces with OTLP. It needs the OpenTelemetry metrics SDK and an OTLP metrics exporter as new dependencies, and every run is a new short-lived process, whose counters start at zero and whose series need a stable identity. - Possibly both, the Pushgateway first.
- The Pushgateway is made for this, and needs no new dependency:
- A file instead of a push?
--metrics-file <path>for the textfile collector of the node exporter is the most common way to monitor cron jobs, and needs neither network nor credentials. It could come first, or next to the push. - For other commands too? Other batch commands, e.g.
opencloud posixfs scanoropencloud storage-users uploads sessions --clean, would benefit in the same way. A shared helper for the commands would make that easy, but is not the scope of this issue. - Metric names: a prefix of their own for the command (e.g.
opencloud_revisions_cleanup_last_run_*), so that they are not mistaken for the server's counters.
AI assistance: Claude Code (claude-opus-5-5) helped analyse the options and draft this issue.
Activity