app/vmselect/prometheus: return __name__ label if match[] query to /api/v1/labels matches at least a single time series

This commit is contained in:
Aliaksandr Valialkin 2020-11-16 13:54:34 +02:00
parent 27a417bcd3
commit 3c1434118e

View File

@ -812,6 +812,9 @@ func labelsWithMatches(matches []string, start, end int64, deadline searchutils.
m[string(tag.Key)] = struct{}{}
}
}
if len(mns) > 0 {
m["__name__"] = struct{}{}
}
} else {
rss, err := netstorage.ProcessSearchQuery(sq, false, deadline)
if err != nil {
@ -831,7 +834,6 @@ func labelsWithMatches(matches []string, start, end int64, deadline searchutils.
return nil, fmt.Errorf("error when data fetching: %w", err)
}
}
labels := make([]string, 0, len(m))
for label := range m {
labels = append(labels, label)