Repository navigation
Alert when the usage history backup has not succeeded for a day - #1890
Merged
Merged
Conversation
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]>
Contributor
There was a problem hiding this comment.
🟢 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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
A failed nightly backup of the usage history raised no alert. This adds one.
registry_usage_backup_last_success_timestamp_seconds.Why this way
The job runs in the
monitoringnamespace. The log collector ships only the registry's own pod logs and thedefaultnamespace'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
REGISTRY_USAGE_BACKUP_SUCCESS_NOT_REPORTEDand finishes successfully. The rule then fires although the snapshot exists; the notification says to look for that line.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.Not verified before deploying
curlbehaves 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.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.