Skip to content
Prev Previous commit
Next Next commit
To allow the duplicate external labels with different components && E…
…mpty labels when no relabel configuration

Signed-off-by: jojohappy <sarahdj0917@gmail.com>
  • Loading branch information
jojohappy committed Oct 8, 2019
commit 94d02ca83c9aab2f44615315793a47bf99aaa7c9
4 changes: 4 additions & 0 deletions pkg/query/storeset.go
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,10 @@ func externalLabelsFromStore(store *storeRef) string {
}
sort.Strings(tsdbLabelSetStrings)

// Append the storeType to the end of list, because the store gateway will be exposed external labels,
// we allow the duplicate external labels with different components.
tsdbLabelSetStrings = append(tsdbLabelSetStrings, store.storeType.String())

return strings.Join(tsdbLabelSetStrings, ",")
}

Expand Down
30 changes: 16 additions & 14 deletions pkg/store/bucket.go
Original file line number Diff line number Diff line change
Expand Up @@ -542,23 +542,25 @@ func (s *BucketStore) Info(context.Context, *storepb.InfoRequest) (*storepb.Info
MaxTime: maxt,
}

labelSets := make(map[uint64][]storepb.Label, len(s.blocks))
for _, bs := range s.blocks {
ls := map[string]string{}
for _, l := range bs.labels {
ls[l.Name] = l.Value
}
if len(s.relabelConfig) != 0 {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would vote to precompute this every sync instead of computing this on every Info which is frequent (at least every 5s)

labelSets := make(map[uint64][]storepb.Label, len(s.blocks))
for _, bs := range s.blocks {
ls := map[string]string{}
for _, l := range bs.labels {
ls[l.Name] = l.Value
}

res := []storepb.Label{}
for k, v := range ls {
res = append(res, storepb.Label{Name: k, Value: v})
res := []storepb.Label{}
for k, v := range ls {
res = append(res, storepb.Label{Name: k, Value: v})
}
labelSets[bs.labels.Hash()] = res
}
labelSets[bs.labels.Hash()] = res
}

res.LabelSets = make([]storepb.LabelSet, 0, len(labelSets))
for _, v := range labelSets {
res.LabelSets = append(res.LabelSets, storepb.LabelSet{Labels: v})
res.LabelSets = make([]storepb.LabelSet, 0, len(labelSets))
for _, v := range labelSets {
res.LabelSets = append(res.LabelSets, storepb.LabelSet{Labels: v})
}
}

return res, nil
Expand Down