Skip to content

Alert when the usage history backup has not succeeded for a day - #1890

Merged
rdimitrov merged 1 commit into
mainfrom
rdimitrov-registry-usage-dashboard-preview
Nov 21, 2026
Merged

rdimitrov merged 1 commit into
mainfrom
rdimitrov-registry-usage-dashboard-preview

Conversation

@rdimitrov

Copy link
Copy Markdown
Member

What

A failed nightly backup of the usage history raised no alert. This adds one.

  • The backup job reports its success. After the snapshot has been stored and checked in full, the job records the time in VictoriaMetrics as registry_usage_backup_last_success_timestamp_seconds.
  • A third usage rule watches it. "Usage history backup missed" fires when the newest record is more than 26 hours old, or when there is none, and that has been so for an hour. It notifies "Registry Dev" like the other two.

Why this way

The job runs in the monitoring namespace. The log collector ships only the registry's own pod logs and the default namespace's events, so nothing about this job reaches any of Grafana's data sources. The registry's own backup alerts are GCP policies set up by a script and cover only the registry's job. Having the job report one number keeps the alert in the repository with the other rules and changes nothing else in the cluster.

Behaviour worth knowing

  • A backup that cannot report still counts as made. If VictoriaMetrics cannot be reached after four tries, the job logs REGISTRY_USAGE_BACKUP_SUCCESS_NOT_REPORTED and finishes successfully. The rule then fires although the snapshot exists; the notification says to look for that line.
  • A backup that has never reported fires too. Right after this is first deployed where alerting is on, no record exists, so the rule would notify between one and two hours later. The README's switching-on steps now include running a backup by hand within the hour.
  • Timing. A missed night passes 26 hours at 05:30 UTC and notifies between 06:30 and 07:30 UTC.
  • Staging gets the reporting step but no rule, as it has no alerting configured.

How it was checked

  • go -C deploy test ./... and the deploy script tests pass. The new assertions fail when the rule reads a different metric name than the job reports, when the job stops reporting, when the rule is missing from the retire file, and when the rule names a data source that is not provisioned.
  • The job's reporting step was run on its own against a local stand-in: accepted (one request, exit 0), rejected every time (four tries, the not-reported line, exit 0), and nothing listening (the same).
  • The rule's expression was run read-only against production's VictoriaMetrics: with the metric absent it returns 9999, and the same shape on an existing metric returns that metric's age in hours.
  • The committed rule and contact point were loaded into Grafana 12.4.14, the version production runs, with only the timings shortened (interval 10s, wait 20s) and a stand-in for the metrics answers:
    • never reported: pending, then firing, then a "[FIRING:1] Usage history backup missed" notification carrying the summary and description;
    • a success reported: back to normal, then "[RESOLVED]";
    • 25.9 hours: normal; 26.1 hours: pending, then firing.

Not verified before deploying

  • That the backup image's curl behaves like the one used locally, and that VictoriaMetrics accepts the record. Staging shows both on merge: a backup run by hand there should leave the metric queryable.
  • The real one-hour interval and one-hour wait.

Rollout

Staging on merge. Production needs a deployment; this change does not touch deploy/Pulumi.gcpProd.yaml, so nothing happens there until one is run. It updates the backup CronJob in place and restarts Grafana once to load the rule.

A failed nightly backup of the usage history raised no alert: the job
runs in the monitoring namespace, whose logs and events reach none of
Grafana's data sources, and the registry's own backup alerts cover
only the registry's job.

The backup job now records the time of each success in VictoriaMetrics,
after its snapshot has been stored and checked in full. A third usage
rule, "Usage history backup missed", fires when the newest record is
more than 26 hours old or when there is none, and that has been so for
an hour. A backup that cannot reach VictoriaMetrics still counts as
made; the job says so in its log and the rule fires.

Co-authored-by: Copilot App <[email protected]>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues were identified for the missed usage-history backup monitoring change.

No open issues 🎉

What changed in this PR

Adds monitoring for missed usage-history backups, extending the existing usage alerts with a success timestamp reported to VictoriaMetrics.

Changes:

  • Reports success after backup verification, without failing the completed backup if reporting fails.
  • Adds a Grafana alert when the last success is over 26 hours old or absent, with a one-hour pending period.
  • Updates provisioning tests, rule retirement, and rollout documentation, including the initial manual backup.
File Description
deploy/​README.md Documents alert behavior, troubleshooting, and initial backup steps.
deploy/​pkg/​k8s/​usage/​alerting/​rules.yaml Adds the backup-age alert routed to Registry Dev.
deploy/​pkg/​k8s/​usage/​alerting/​retired.yaml Deletes the new rule when the collector is retired.
deploy/​pkg/​k8s/​usage_collector.go Extracts the VictoriaMetrics URL for reuse by the backup job.
deploy/​pkg/​k8s/​usage_collector_test.go Updates assertions for reporting, three rules, metric consistency, and data sources.
deploy/​pkg/​k8s/​usage_backup.go Reports the success timestamp with retries and logs reporting failures.

Review effort: Balanced

@rdimitrov
rdimitrov merged commit cb2710c into main Nov 21, 2026
10 checks passed
@rdimitrov
rdimitrov deleted the rdimitrov-registry-usage-dashboard-preview branch November 21, 2026 23:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants