mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2025-03-11 15:34:56 +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
43754ff420
commit
7d178a40bd
1 changed files with 11 additions and 9 deletions
|
@ -283,16 +283,18 @@ func labelValuesWithMatches(labelName string, matches []string, start, end int64
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add `labelName!=''` tag filter in order to filter out series without the labelName.
|
// Add `labelName!=''` tag filter in order to filter out series without the labelName.
|
||||||
key := []byte(labelName)
|
// There is no need in adding `__name__!=''` filter, since all the time series should
|
||||||
if string(key) == "__name__" {
|
// already have non-empty name.
|
||||||
key = nil
|
if labelName != "__name__" {
|
||||||
}
|
key := []byte(labelName)
|
||||||
for i, tfs := range tagFilterss {
|
for i, tfs := range tagFilterss {
|
||||||
tagFilterss[i] = append(tfs, storage.TagFilter{
|
tagFilterss[i] = append(tfs, storage.TagFilter{
|
||||||
Key: key,
|
Key: key,
|
||||||
IsNegative: true,
|
IsNegative: true,
|
||||||
})
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if start >= end {
|
if start >= end {
|
||||||
end = start + defaultStep
|
end = start + defaultStep
|
||||||
|
|
Loading…
Reference in a new issue