Skip to content
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(blooms): Only write key and key=value to blooms #14686

Merged
merged 2 commits into from
Oct 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions docs/sources/operations/bloom-filters.md
Original file line number Diff line number Diff line change
Expand Up @@ -176,10 +176,10 @@ If there are new TSDB files or any of them have changed, the planner will create
The builder pulls a task from the planner's queue and processes the containing streams and chunks.
For a given stream, the builder will iterate through all the log lines inside its new chunks and build a bloom for the stream.
In case of changes for a previously processed TSDB file, builders will try to reuse blooms from existing blocks instead of building new ones from scratch.
The builder converts structured metadata from each log line of each chunk of a stream and appends the hash of each key, value, and key-value pair to the bloom, followed by the hashes combined with the chunk identifier.
The builder converts structured metadata from each log line of each chunk of a stream and appends the hash of each key, and key-value pair to the bloom, followed by the hashes combined with the chunk identifier.
The first set of hashes allows gateways to skip whole streams, while the latter is for skipping individual chunks.

For example, given structured metadata `foo=bar` in the chunk `c6dj8g`, we append to the stream bloom the following hashes: `hash("foo")`, `hash("bar")`, `hash("foo=bar")`, `hash("c6dj8g" + "foo")` ... `hash("c6dj8g" + "foo=bar")`.
For example, given structured metadata `foo=bar` in the chunk `c6dj8g`, we append to the stream bloom the following hashes: `hash("foo")`, `hash("foo=bar")`, `hash("c6dj8g" + "foo")` and `hash("c6dj8g" + "foo=bar")`.

## Query sharding

Expand Down
1 change: 0 additions & 1 deletion pkg/storage/bloom/v1/tokenizer.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ func (t *StructuredMetadataTokenizer) Tokens(kv push.LabelAdapter) iter.Iterator
combined := fmt.Sprintf("%s=%s", kv.Name, kv.Value)
t.tokens = append(t.tokens[:0],
kv.Name, t.prefix+kv.Name,
kv.Value, t.prefix+kv.Value,
combined, t.prefix+combined,
)
return iter.NewSliceIter(t.tokens)
Expand Down
2 changes: 1 addition & 1 deletion pkg/storage/bloom/v1/tokenizer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ func TestStructuredMetadataTokenizer(t *testing.T) {
tokenizer := NewStructuredMetadataTokenizer("chunk")

metadata := push.LabelAdapter{Name: "pod", Value: "loki-1"}
expected := []string{"pod", "chunkpod", "loki-1", "chunkloki-1", "pod=loki-1", "chunkpod=loki-1"}
expected := []string{"pod", "chunkpod", "pod=loki-1", "chunkpod=loki-1"}

tokenIter := tokenizer.Tokens(metadata)
got, err := v2.Collect(tokenIter)
Expand Down
Loading