|
|
|
@ -33,10 +33,14 @@ type Querier interface {
|
|
|
|
|
|
|
|
|
|
// LabelValues returns all potential values for a label name.
|
|
|
|
|
LabelValues(string) ([]string, error)
|
|
|
|
|
|
|
|
|
|
// LabelValuesFor returns all potential values for a label name.
|
|
|
|
|
// under the constraint of another label.
|
|
|
|
|
LabelValuesFor(string, labels.Label) ([]string, error)
|
|
|
|
|
|
|
|
|
|
// LabelNames returns all the unique label names present in the block in sorted order.
|
|
|
|
|
LabelNames() ([]string, error)
|
|
|
|
|
|
|
|
|
|
// Close releases the resources of the Querier.
|
|
|
|
|
Close() error
|
|
|
|
|
}
|
|
|
|
@ -60,6 +64,28 @@ func (q *querier) LabelValues(n string) ([]string, error) {
|
|
|
|
|
return q.lvals(q.blocks, n)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// LabelNames returns all the unique label names present querier blocks.
|
|
|
|
|
func (q *querier) LabelNames() ([]string, error) {
|
|
|
|
|
labelNamesMap := make(map[string]struct{})
|
|
|
|
|
for _, b := range q.blocks {
|
|
|
|
|
names, err := b.LabelNames()
|
|
|
|
|
if err != nil {
|
|
|
|
|
return nil, errors.Wrap(err, "LabelNames() from Querier")
|
|
|
|
|
}
|
|
|
|
|
for _, name := range names {
|
|
|
|
|
labelNamesMap[name] = struct{}{}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
labelNames := make([]string, 0, len(labelNamesMap))
|
|
|
|
|
for name := range labelNamesMap {
|
|
|
|
|
labelNames = append(labelNames, name)
|
|
|
|
|
}
|
|
|
|
|
sort.Strings(labelNames)
|
|
|
|
|
|
|
|
|
|
return labelNames, nil
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (q *querier) lvals(qs []Querier, n string) ([]string, error) {
|
|
|
|
|
if len(qs) == 0 {
|
|
|
|
|
return nil, nil
|
|
|
|
@ -187,6 +213,10 @@ func (q *blockQuerier) LabelValues(name string) ([]string, error) {
|
|
|
|
|
return res, nil
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (q *blockQuerier) LabelNames() ([]string, error) {
|
|
|
|
|
return q.index.LabelNames()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (q *blockQuerier) LabelValuesFor(string, labels.Label) ([]string, error) {
|
|
|
|
|
return nil, fmt.Errorf("not implemented")
|
|
|
|
|
}
|
|
|
|
|