From 834e2ad85553d0862ee14345f6cd6f7f2c654011 Mon Sep 17 00:00:00 2001 From: Aliaksandr Valialkin Date: Wed, 9 Oct 2024 15:53:15 +0200 Subject: [PATCH] lib/logstorage: disallow using by as the first word in log filters, since it frequently clashes with `stats by(...)` pipe where `stats` word is omitted (cherry picked from commit 6acf543b90a1fe2a53b23de01ecb80812353dd65) --- lib/logstorage/parser.go | 2 +- lib/logstorage/pipe.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/logstorage/parser.go b/lib/logstorage/parser.go index 53b5293b57..45b3c2691d 100644 --- a/lib/logstorage/parser.go +++ b/lib/logstorage/parser.go @@ -717,7 +717,7 @@ func ParseQueryAtTimestamp(s string, timestamp int64) (*Query, error) { // Verify the first token doesn't match pipe names. firstToken := strings.ToLower(lex.rawToken) if _, ok := pipeNames[firstToken]; ok { - return nil, fmt.Errorf("the query [%s] cannot start with pipe - it must start with madatory filter; see https://docs.victoriametrics.com/victorialogs/logsql/#query-syntax; "+ + return nil, fmt.Errorf("the query [%s] cannot start with pipe - it must start with mandatory filter; see https://docs.victoriametrics.com/victorialogs/logsql/#query-syntax; "+ "if the filter isn't missing, then please put the first word of the filter into quotes: %q", s, firstToken) } diff --git a/lib/logstorage/pipe.go b/lib/logstorage/pipe.go index a8dcff2a68..d2af609c1e 100644 --- a/lib/logstorage/pipe.go +++ b/lib/logstorage/pipe.go @@ -317,7 +317,7 @@ var pipeNames = func() map[string]struct{} { "replace", "replace_regexp", "sort", "order", - "stats", + "stats", "by", "stream_context", "top", "uniq",