Created
March 31, 2024 20:14
-
-
Save kavirajk/085d4a81b6e913fbb9a013b1e07644d4 to your computer and use it in GitHub Desktop.
LogQL linefilters bug
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"github.com/grafana/loki/pkg/logql/syntax" | |
) | |
func main() { | |
q := `{app="loki"}!= "foo" or "bar"` // with single linefilters | |
expr, err := syntax.ParseLogSelector(q, true) | |
if err != nil { | |
panic(err) | |
} | |
fmt.Printf("query=%v\nparsed=%v\n", q, expr.String()) | |
fmt.Println("---------------------") | |
q2 := `{app="loki"}!= "test" != "foo" or "bar"` // with chain of linefilters | |
expr2, err := syntax.ParseLogSelector(q2, true) | |
if err != nil { | |
panic(err) | |
} | |
fmt.Printf("query=%v\nparsed=%v\n", q2, expr2.String()) | |
} | |
// Output | |
// query={app="loki"}!= "foo" or "bar" | |
// parsed={app="loki"} != "foo" != "bar" | |
// --------------------- | |
// query={app="loki"}!= "test" != "foo" or "bar" | |
// parsed={app="loki"} != "test" != "bar" | |
// note `foo` is missing on the second query. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment