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 852aed62f7
commit 2f4421b86c

View file

@ -886,6 +886,9 @@ func labelsWithMatches(at *auth.Token, denyPartialResponse bool, matches []strin
m[string(tag.Key)] = struct{}{}
}
}
if len(mns) > 0 {
m["__name__"] = struct{}{}
}
} else {
rss, isPartialResponse, err := netstorage.ProcessSearchQuery(at, denyPartialResponse, sq, false, deadline)
if err != nil {
@ -906,7 +909,6 @@ func labelsWithMatches(at *auth.Token, denyPartialResponse bool, matches []strin
return nil, false, fmt.Errorf("error when data fetching: %w", err)
}
}
labels := make([]string, 0, len(m))
for label := range m {
labels = append(labels, label)