diff --git a/cmd/thanos/sidecar.go b/cmd/thanos/sidecar.go index e58e6779dd..fd00fbe177 100644 --- a/cmd/thanos/sidecar.go +++ b/cmd/thanos/sidecar.go @@ -229,7 +229,7 @@ func runSidecar( return nil }) if err != nil { - return errors.Wrap(err, "buildinfo query") + return errors.Wrap(err, "failed to get prometheus version") } return nil }, func(error) { diff --git a/pkg/store/prometheus.go b/pkg/store/prometheus.go index 37f7b369dd..b1bf61e65e 100644 --- a/pkg/store/prometheus.go +++ b/pkg/store/prometheus.go @@ -520,11 +520,17 @@ func (p *PrometheusStore) LabelValues(ctx context.Context, r *storepb.LabelValue if err != nil { return nil, err } + + // using set to handle duplicate values. + labelValuesSet := make(map[string]struct{}) for _, s := range sers { if val, exists := s[r.Label]; exists { - vals = append(vals, val) + labelValuesSet[val] = struct{}{} } } + for key := range labelValuesSet { + vals = append(vals, key) + } } sort.Strings(vals) return &storepb.LabelValuesResponse{Values: vals}, nil