-
Notifications
You must be signed in to change notification settings - Fork 3.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add cache usage statistics #6317
Add cache usage statistics #6317
Conversation
Signed-off-by: Danny Kopping <[email protected]>
Signed-off-by: Danny Kopping <[email protected]>
Signed-off-by: Danny Kopping <[email protected]>
Signed-off-by: Danny Kopping <[email protected]>
Signed-off-by: Danny Kopping <[email protected]>
Signed-off-by: Danny Kopping <[email protected]>
Signed-off-by: Danny Kopping <[email protected]>
ChunkCache CacheType = "chunk" | ||
IndexCache = "index" | ||
ResultCache = "result" | ||
WriteDedupeCache = "write-dedupe" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've added the write dedupe cache here for the sake of completeness, but it's not yet displayed along with the others.
Documenting function Signed-off-by: Danny Kopping <[email protected]>
./tools/diff_coverage.sh ../loki-main/test_results.txt test_results.txt ingester,distributor,querier,querier/queryrange,iter,storage,chunkenc,logql,loki Change in test coverage per package. Green indicates 0 or positive change, red indicates that test coverage for a package fell. + ingester 0%
+ distributor 0%
+ querier 0%
+ querier/queryrange 0.1%
+ iter 0%
+ storage 0%
+ chunkenc 0%
+ logql 0%
+ loki 0% |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
few nits but looks great
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks awesome!
Signed-off-by: Danny Kopping <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the review! Addressed your comments
./tools/diff_coverage.sh ../loki-main/test_results.txt test_results.txt ingester,distributor,querier,querier/queryrange,iter,storage,chunkenc,logql,loki Change in test coverage per package. Green indicates 0 or positive change, red indicates that test coverage for a package fell. + ingester 0%
+ distributor 0%
+ querier 0%
+ querier/queryrange 0%
+ iter 0%
+ storage 0%
+ chunkenc 0%
+ logql 0%
+ loki 0% |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
…tion If we keep the stats collection in pkg/storage/chunk/cache/instrumented.go, then any implementation that wraps it will cause the stats collected to be incomplete. For example: NewBackground(cacheName, cfg.Background, Instrument(cacheName, cache, reg), reg)) - the background cache requests are not collected Signed-off-by: Danny Kopping <[email protected]>
Signed-off-by: Danny Kopping <[email protected]>
./tools/diff_coverage.sh ../loki-main/test_results.txt test_results.txt ingester,distributor,querier,querier/queryrange,iter,storage,chunkenc,logql,loki Change in test coverage per package. Green indicates 0 or positive change, red indicates that test coverage for a package fell. + ingester 0%
- distributor -0.3%
+ querier 0%
+ querier/queryrange 0.1%
+ iter 0%
+ storage 0%
+ chunkenc 0%
+ logql 0.5%
+ loki 0% |
./tools/diff_coverage.sh ../loki-main/test_results.txt test_results.txt ingester,distributor,querier,querier/queryrange,iter,storage,chunkenc,logql,loki Change in test coverage per package. Green indicates 0 or positive change, red indicates that test coverage for a package fell. - ingester -0.1%
+ distributor 0%
+ querier 0%
+ querier/queryrange 0.1%
+ iter 0%
+ storage 0%
+ chunkenc 0%
+ logql 0%
+ loki 0% |
* Adding cache statistics Signed-off-by: Danny Kopping <[email protected]> * Adding metrics to metrics.go Signed-off-by: Danny Kopping <[email protected]> * Creating new stats context for use in metric queries middleware Signed-off-by: Danny Kopping <[email protected]> * Clean up unnecessary log fields Signed-off-by: Danny Kopping <[email protected]> * Fixing tests Signed-off-by: Danny Kopping <[email protected]> * Adding stats tests Signed-off-by: Danny Kopping <[email protected]> * CHANGELOG entry Signed-off-by: Danny Kopping <[email protected]> * Appeasing the linter Documenting function Signed-off-by: Danny Kopping <[email protected]> * Moving CHANGELOG entry to appropriate section Signed-off-by: Danny Kopping <[email protected]> * Implementing a stats collector cache wrapper to simplify stats collection If we keep the stats collection in pkg/storage/chunk/cache/instrumented.go, then any implementation that wraps it will cause the stats collected to be incomplete. For example: NewBackground(cacheName, cfg.Background, Instrument(cacheName, cache, reg), reg)) - the background cache requests are not collected Signed-off-by: Danny Kopping <[email protected]> * Fixing tests Signed-off-by: Danny Kopping <[email protected]>
* Adding cache statistics Signed-off-by: Danny Kopping <[email protected]> * Adding metrics to metrics.go Signed-off-by: Danny Kopping <[email protected]> * Creating new stats context for use in metric queries middleware Signed-off-by: Danny Kopping <[email protected]> * Clean up unnecessary log fields Signed-off-by: Danny Kopping <[email protected]> * Fixing tests Signed-off-by: Danny Kopping <[email protected]> * Adding stats tests Signed-off-by: Danny Kopping <[email protected]> * CHANGELOG entry Signed-off-by: Danny Kopping <[email protected]> * Appeasing the linter Documenting function Signed-off-by: Danny Kopping <[email protected]> * Moving CHANGELOG entry to appropriate section Signed-off-by: Danny Kopping <[email protected]> * Implementing a stats collector cache wrapper to simplify stats collection If we keep the stats collection in pkg/storage/chunk/cache/instrumented.go, then any implementation that wraps it will cause the stats collected to be incomplete. For example: NewBackground(cacheName, cfg.Background, Instrument(cacheName, cache, reg), reg)) - the background cache requests are not collected Signed-off-by: Danny Kopping <[email protected]> * Fixing tests Signed-off-by: Danny Kopping <[email protected]>
This reverts commit 36e0979.
What this PR does / why we need it:
This PR adds cache statistics for the chunk, index, and result caches. The statistics are collected in the same mechanism that is used currently for ingester/querier stats. The PR also adds some pertinent info to
metrics.go
which shows cache usage on a per-query, per-tenant basis.This PR should be read with #6289.
Running
logcli query <other args> --stats
will now return extra stats:Which issue(s) this PR fixes:
#6318
Special notes for your reviewer:
Statistics were not being collected correctly in the
queryrange.StatsCollectorMiddleware
. I believe the statistics were being discarded by thepkg/querier/queryrange/queryrangebase/results_cache.go
middleware, but creating a new stats context in theStatsCollectorMiddleware
seems to have fixed the issue. This code is pretty hard for me to reason about, so I would appreciate @cyriltovena's review on that since he was the original author, I believe. See baa239c.Checklist
CHANGELOG.md
.docs/sources/upgrading/_index.md