Fix duplicate label values from ingester streams (#9629)

pull/9627/head
Periklis Tsirakidis 2 years ago committed by GitHub
parent c6f809a738
commit 69392de8b6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      CHANGELOG.md
  2. 8
      pkg/ingester/instance.go
  3. 1
      pkg/ingester/instance_test.go

@ -43,6 +43,7 @@
* [9176](https://github.com/grafana/loki/pull/9176) **DylanGuedes**: Fix incorrect association of per-stream rate limit when sharding is enabled.
* [9463](https://github.com/grafana/loki/pull/9463) **Totalus**: Fix OpenStack Swift client object listing to fetch all the objects properly.
* [9495](https://github.com/grafana/loki/pull/9495) **thampiotr**: Promtail: Fix potential goroutine leak in file tailer.
* [9629](https://github.com/grafana/loki/pull/9629) **periklis**: Fix duplicate label values from ingester streams.
##### Changes

@ -480,15 +480,15 @@ func (i *instance) Label(ctx context.Context, req *logproto.LabelRequest, matche
}, nil
}
labels := make([]string, 0)
labels := util.NewUniqueStrings(0)
err := i.forMatchingStreams(ctx, *req.Start, matchers, nil, func(s *stream) error {
for _, label := range s.labels {
if req.Values && label.Name == req.Name {
labels = append(labels, label.Value)
labels.Add(label.Value)
continue
}
if !req.Values {
labels = append(labels, label.Name)
labels.Add(label.Name)
}
}
return nil
@ -498,7 +498,7 @@ func (i *instance) Label(ctx context.Context, req *logproto.LabelRequest, matche
}
return &logproto.LabelResponse{
Values: labels,
Values: labels.Strings(),
}, nil
}

@ -288,6 +288,7 @@ func setupTestStreams(t *testing.T) (*instance, time.Time, int) {
testStreams := []logproto.Stream{
{Labels: "{app=\"test\",job=\"varlogs\"}", Entries: entries(5, currentTime)},
{Labels: "{app=\"test2\",job=\"varlogs\"}", Entries: entries(5, currentTime.Add(6*time.Nanosecond))},
{Labels: "{app=\"test\",job=\"varlogs2\"}", Entries: entries(5, currentTime.Add(12*time.Nanosecond))},
}
for _, testStream := range testStreams {

Loading…
Cancel
Save