diff --git a/app/vmselect/promql/parser.go b/app/vmselect/promql/parser.go index 7ac978efd0..aafe214387 100644 --- a/app/vmselect/promql/parser.go +++ b/app/vmselect/promql/parser.go @@ -1128,6 +1128,10 @@ func (tfe *tagFilterExpr) toTagFilter() (*storage.TagFilter, error) { } else { tf.Value = []byte(tfe.Value.S) } + if string(tf.Key) == "__name__" { + // This is required for storage.Search + tf.Key = nil + } tf.IsRegexp = tfe.IsRegexp tf.IsNegative = tfe.IsNegative if !tf.IsRegexp { diff --git a/app/vmselect/promql/parser_test.go b/app/vmselect/promql/parser_test.go index 0352146d71..8f4d350890 100644 --- a/app/vmselect/promql/parser_test.go +++ b/app/vmselect/promql/parser_test.go @@ -119,7 +119,7 @@ func TestParsePromQLSuccess(t *testing.T) { same("WITH") same("With") // identifiers with with escape chars - same(`{__name__="foo bar"}`) + same(`foo\ bar`) same(`foo\-bar\{{baz\+bar="aa"}`) another(`\x2E\x2ef\oo{b\xEF\ar="aa"}`, `\x2e.foo{b\xefar="aa"}`) // Duplicate filters @@ -305,7 +305,7 @@ func TestParsePromQLSuccess(t *testing.T) { `(({job="test", i="bar"} + {job="test", i="bar", x="d"}) + foo{job="test", i="bar"}) + ctx(1)`) another(`with (foo = bar) {__name__=~"foo"}`, `{__name__=~"foo"}`) another(`with (foo = bar) foo{__name__="foo"}`, `bar`) - another(`with (foo = bar) {__name__="foo", x="y"}`, `{__name__="foo", x="y"}`) + another(`with (foo = bar) {__name__="foo", x="y"}`, `bar{x="y"}`) another(`with (foo(bar) = {__name__!="bar"}) foo(x)`, `{__name__!="bar"}`) another(`with (foo(bar) = bar{__name__="bar"}) foo(x)`, `x`) another(`with (foo\-bar(baz) = baz + baz) foo\-bar((x,y))`, `(x, y) + (x, y)`)