diff --git a/app/vmselect/prometheus/prometheus.go b/app/vmselect/prometheus/prometheus.go index 8ccfca500..91890a686 100644 --- a/app/vmselect/prometheus/prometheus.go +++ b/app/vmselect/prometheus/prometheus.go @@ -283,16 +283,18 @@ func labelValuesWithMatches(labelName string, matches []string, start, end int64 if err != nil { return nil, err } + // Add `labelName!=''` tag filter in order to filter out series without the labelName. - key := []byte(labelName) - if string(key) == "__name__" { - key = nil - } - for i, tfs := range tagFilterss { - tagFilterss[i] = append(tfs, storage.TagFilter{ - Key: key, - IsNegative: true, - }) + // There is no need in adding `__name__!=''` filter, since all the time series should + // already have non-empty name. + if labelName != "__name__" { + key := []byte(labelName) + for i, tfs := range tagFilterss { + tagFilterss[i] = append(tfs, storage.TagFilter{ + Key: key, + IsNegative: true, + }) + } } if start >= end { end = start + defaultStep