From 2f4421b86cb99446906a1fb60ee26a9404f59b4e Mon Sep 17 00:00:00 2001 From: Aliaksandr Valialkin Date: Mon, 16 Nov 2020 13:54:34 +0200 Subject: [PATCH] app/vmselect/prometheus: return `__name__` label if `match[]` query to `/api/v1/labels` matches at least a single time series --- app/vmselect/prometheus/prometheus.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/vmselect/prometheus/prometheus.go b/app/vmselect/prometheus/prometheus.go index 689785516..7ffd6270c 100644 --- a/app/vmselect/prometheus/prometheus.go +++ b/app/vmselect/prometheus/prometheus.go @@ -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)