Repository navigation
freshness asked Prometheus 98 times per fill, now once - #2942
Merged
Merged
Conversation
/api/freshness ran one instant query per live spec on every 30 s cache fill: 509k Prom queries a day, 30% of all outbound calls the project made, each billed as an Observability Event. Prometheus.dataAgesSec() folds them into one union query. timestamp() must wrap the bare selector, otherwise it returns evaluation time and every recording rule reads 0 s old, so each metric gets its own term. Checked live: 246/246 specs agree with the per-spec probe within one scrape interval, 77 metrics in ~240 ms.
Flotapponnier
force-pushed
the
fix/freshness-one-prom-query
branch
from
October 10, 2026 13:57
2fc409a to
ebdc625
Compare
Flotapponnier
added a commit
that referenced
this pull request
Oct 10, 2026
/api/freshness ran one instant query per live spec on every 30 s cache fill: 509k Prom queries a day, 30% of all outbound calls the project made, each billed as an Observability Event. Prometheus.dataAgesSec() folds them into one union query. timestamp() must wrap the bare selector, otherwise it returns evaluation time and every recording rule reads 0 s old, so each metric gets its own term. Checked live: 246/246 specs agree with the per-spec probe within one scrape interval, 77 metrics in ~240 ms. (cherry picked from commit e8a3260)
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.
/api/freshnessran one Prometheus instant query per live spec on every cache fill (30 s):98 per fill, 509k a day, 30% of every outbound call OCB functions make. Each one bills as an Observability Event, the largest line on the Vercel bill ($2.4/day).Prometheus.dataAgesSec()returns every metric's age in one union query. Each metric gets its owntimestamp(<metric>)term becausetimestamp()only returns the sample time on a bare selector; wrapped inlabel_replaceit returns evaluation time and every recording rule reads 0 s old (caught on the first live comparison).Verified against prod Prometheus: 246/246 live specs agree with the old per-spec probe within one scrape interval; 77 distinct metrics in ~240 ms. Unit test added for the batching and the name filter.
Expected effect:
500k fewer outbound calls/day ($16/month on events, plus Fluid CPU and Prom load on the VPS).