Repository navigation
Judge usage drift only where there is enough evidence for it - #1884
Merged
Merged
Conversation
The drift rule compares the newest day's log-based estimate with the gateway counters and fires beyond 10 percent. On a day with little traffic a handful of listing records stand for all listing data, so the estimate strays that far by chance: in staging most quiet days would have fired. Judge a day only when it has at least 20,000 sampled records. A busy day is sampled to about 100,000, so the rule still covers every day that the dashboards are read for. Co-authored-by: Copilot App <[email protected]>
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
The guard can miss severe log loss on busy days and still allow false data-drift alerts because it counts all records rather than sampled listings.
2 open issues
What changed in this PR
This PR adds a minimum-sample guard to the usage collector’s Grafana drift alert, aiming to reduce noisy alerts on low-traffic days.
Changes:
- Evaluate the newest stored day’s request and data drift only when it has at least 20,000 sampled records.
- Document the cutoff and its rationale in the deployment guide and alert annotations.
| File | Description |
|---|---|
| deploy/README.md | Documents the minimum sample size for drift alerts. |
| deploy/pkg/k8s/usage/alerting/rules.yaml | Adds the sample-size guard and updates the alert explanation. |
Review effort: Balanced
Review of the previous commit found that a single threshold on sampled records was wrong in both directions: - A busy day whose access records went missing has few records, so it was excluded, and the loss went unreported. - A day with many lookup records and a single listing record passed, although that one record stands for all listing data. Judge the request estimate whenever the gateway counted at least 1,000 requests, whatever was read from the logs. Judge the data estimate when at least 1,000 listing records were sampled, taken as the day's listing requests divided by the largest weight one listing record carries, which never overstates the count. Co-authored-by: Copilot App <[email protected]>
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
The "Usage estimate drifted from the gateway counters" rule now judges its two estimates separately, each only when there is enough evidence for it:
Why
The rule fires when the log-based estimate of requests or data is more than 10% from the gateway's counters. On a day with little traffic, a handful of listing records stand for all listing data, so the data estimate strays that far by chance. In staging, most quiet days would have fired.
The first version of this change used one threshold on the number of sampled records. Review found it wrong in both directions, and the second commit replaces it:
Effect
How it was checked
go -C deploy test ./...passes.Not checked: the rule was not loaded into a Grafana instance again; only its SQL and annotation text changed.