-
Notifications
You must be signed in to change notification settings - Fork 3.4k
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
feat(caching): Support caching /series
and /labels
query results
#11539
Merged
Merged
Changes from all commits
Commits
Show all changes
27 commits
Select commit
Hold shift + click to select a range
54b42a2
feature(cache): Support caching for metadata query results
kavirajk 6139807
idk
kavirajk fe12193
fix TestSeriesCache
ashwanthgoli ec99784
Complete series cache tests
kavirajk 7158994
have separate loki config to run with memcached
kavirajk e4d1302
Add cache hit metrics and configs to test
kavirajk 4cb7145
fix memcached config
kavirajk 55a7c8a
stats.proto change to support series cache
kavirajk 64175cf
tidy up the tests
ashwanthgoli d716461
update failing tests to include the new stats
ashwanthgoli 01f4792
apply default configs to series cache
ashwanthgoli 13ff271
add test for GenerateCacheKey
ashwanthgoli 634b43b
make doc
ashwanthgoli c654c82
Merge branch 'main' into kavirajk/metadata-caching
ashwanthgoli ed3db1a
preserve cache prefix
ashwanthgoli 836b9ee
fixup! preserve cache prefix
ashwanthgoli dfe174f
s/querier.cache-series-results/frontend.cache-series-results
ashwanthgoli ee9667f
retain headers when merging series response
ashwanthgoli 2cc04cf
add label results cache
ashwanthgoli bb2280d
make format && make doc
ashwanthgoli 40f69e3
add CHANGELOG
ashwanthgoli db966bd
Merge branch 'main' into kavirajk/metadata-caching
ashwanthgoli ccd4a55
introduce split_metadata_queries_by_interval
ashwanthgoli 32f4d20
make doc
ashwanthgoli 92a7e43
Make flags prefix consistent with rest of result cache flags
kavirajk 8706162
nit
ashwanthgoli 40d64ef
PR remarks
kavirajk File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
auth_enabled: false | ||
|
||
server: | ||
http_listen_port: 3100 | ||
grpc_listen_port: 9096 | ||
|
||
common: | ||
instance_addr: 127.0.0.1 | ||
path_prefix: /tmp/loki | ||
storage: | ||
filesystem: | ||
chunks_directory: /tmp/loki/chunks | ||
rules_directory: /tmp/loki/rules | ||
replication_factor: 1 | ||
ring: | ||
kvstore: | ||
store: inmemory | ||
|
||
query_range: | ||
align_queries_with_step: true | ||
cache_index_stats_results: true | ||
cache_results: true | ||
cache_volume_results: true | ||
cache_series_results: true | ||
series_results_cache: | ||
cache: | ||
default_validity: 12h | ||
memcached_client: | ||
consistent_hash: true | ||
addresses: "dns+localhost:11211" | ||
max_idle_conns: 16 | ||
timeout: 500ms | ||
update_interval: 1m | ||
index_stats_results_cache: | ||
cache: | ||
default_validity: 12h | ||
memcached_client: | ||
consistent_hash: true | ||
addresses: "dns+localhost:11211" | ||
max_idle_conns: 16 | ||
timeout: 500ms | ||
update_interval: 1m | ||
max_retries: 5 | ||
results_cache: | ||
cache: | ||
default_validity: 12h | ||
memcached_client: | ||
consistent_hash: true | ||
addresses: "dns+localhost:11211" | ||
max_idle_conns: 16 | ||
timeout: 500ms | ||
update_interval: 1m | ||
volume_results_cache: | ||
cache: | ||
default_validity: 12h | ||
memcached_client: | ||
consistent_hash: true | ||
addresses: "dns+localhost:11211" | ||
max_idle_conns: 16 | ||
timeout: 500ms | ||
update_interval: 1m | ||
|
||
schema_config: | ||
configs: | ||
- from: 2020-10-24 | ||
store: tsdb | ||
object_store: filesystem | ||
schema: v12 | ||
index: | ||
prefix: index_ | ||
period: 24h | ||
|
||
ruler: | ||
alertmanager_url: http://localhost:9093 | ||
|
||
# By default, Loki will send anonymous, but uniquely-identifiable usage and configuration | ||
# analytics to Grafana Labs. These statistics are sent to https://stats.grafana.org/ | ||
# | ||
# Statistics help us better understand how Loki is used, and they show us performance | ||
# levels for most users. This helps us prioritize features and documentation. | ||
# For more information on what's sent, look at | ||
# https://github.com/grafana/loki/blob/main/pkg/analytics/stats.go | ||
# Refer to the buildReport method to see what goes into a report. | ||
# | ||
# If you would like to disable reporting, uncomment the following lines: | ||
#analytics: | ||
# reporting_enabled: false |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.
Oops, something went wrong.
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.
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 don't see much value in having separate cache configs for this, label results, and normal result cache. IMHO we should err on the side of simplicity until we find a very compelling case for needing separate caches for all 3.
Our config is already monstrously complex; we should do what we can to not make it more so.
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.
agree to this. one downside is that we would lose granularity with stats and metric collection since they are tried to the cache instance. labels, series and results caching all would be clubbed together.
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.
How valuable are the metrics? Could we use a different label based on which "subcomponent" is observing metrics?
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.
Good point. Thought about this when introducing it. Now we have so much repeated configs for normal results cache (metric range queries), index stats, volume, labels, series and for metric instant queries in future. All have exactly same configs.
One downside is it's hard to clean this up without breaking changes I think. Other option is to introduce shared config with "subcomponent" label but only for labels and series without breaking existing configs, then we loose the consistency with how we configure different results cache.
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 would be fine with leaving this as is for now but combining them all in v3.0 with breaking changes, thoughts?
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.
Good idea. Adding it to the epic 👍
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.
another thing that I am worried about is blowing up the size of stats proto. does encoding ignore fields that are not set? if that's the case we don't have to worry about this
only one of these would be set for a given request, I guess we could just collapse this into a single field with a new cache type field
loki/pkg/logqlmodel/stats/stats.proto
Lines 40 to 60 in 40d64ef