diff --git a/pkg/ingester/instance.go b/pkg/ingester/instance.go index 99bf587b21e85..eb37350ddb426 100644 --- a/pkg/ingester/instance.go +++ b/pkg/ingester/instance.go @@ -589,9 +589,28 @@ type UniqueValues map[string]struct{} // LabelsWithValues returns the label names with all the unique values depending on the request func (i *instance) LabelsWithValues(ctx context.Context, startTime time.Time, matchers ...*labels.Matcher) (map[string]UniqueValues, error) { - // TODO (shantanu): Figure out how to get the label names from index directly when no matchers are given. - labelMap := make(map[string]UniqueValues) + if len(matchers) == 0 { + labelsFromIndex, err := i.index.LabelNames(startTime, nil) + if err != nil { + return nil, err + } + + for _, label := range labelsFromIndex { + values, err := i.index.LabelValues(startTime, label, nil) + if err != nil { + return nil, err + } + existingValues, exists := labelMap[label] + if !exists { + existingValues = make(map[string]struct{}) + } + for _, v := range values { + existingValues[v] = struct{}{} + } + } + } + err := i.forMatchingStreams(ctx, startTime, matchers, nil, func(s *stream) error { for _, label := range s.labels { v, exists := labelMap[label.Name] diff --git a/pkg/querier/queryrange/codec.go b/pkg/querier/queryrange/codec.go index 2d36eafc0a5da..80d8304928b24 100644 --- a/pkg/querier/queryrange/codec.go +++ b/pkg/querier/queryrange/codec.go @@ -268,18 +268,6 @@ type DetectedLabelsRequest struct { logproto.DetectedLabelsRequest } -// NewDetectedLabelsRequest creates a new request for detected labels -func NewDetectedLabelsRequest(start, end time.Time, query, path string) *DetectedLabelsRequest { - return &DetectedLabelsRequest{ - DetectedLabelsRequest: logproto.DetectedLabelsRequest{ - Start: &start, - End: &end, - Query: query, - }, - path: path, - } -} - func (r *DetectedLabelsRequest) AsProto() *logproto.DetectedLabelsRequest { return &r.DetectedLabelsRequest }