mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-11-21 14:44:00 +00:00
app/vmselect/prometheus: do not add __name__!=
filter when searching for all the matching metric names via /api/v1/label/__name__/values
with non-empty label filter
This should reduce query time. Updates https://github.com/VictoriaMetrics/VictoriaMetrics/issues/343
This commit is contained in:
parent
6a1aab88fd
commit
d23df53ba2
1 changed files with 11 additions and 9 deletions
|
@ -340,16 +340,18 @@ func labelValuesWithMatches(at *auth.Token, labelName string, matches []string,
|
|||
if err != nil {
|
||||
return nil, false, 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
|
||||
|
|
Loading…
Reference in a new issue