Skip to content

SigNoz is an open-source, OpenTelemetry-native observability platform for your team and their AI agents. Get logs, metrics, and traces in one tool with features like APM, distributed tracing, log management, infra monitoring, etc. Combined with SigNoz MCP and a native AI teammate (in SigNoz Cloud) it helps you build more resilient apps.

OR support added with contains

nityanandagohain5894acdb2d48
diff --git a/pkg/query-service/app/logs/parser.go b/pkg/query-service/app/logs/parser.go
index 8b24c940ac..d709036cf3 100644
--- a/pkg/query-service/app/logs/parser.go
+++ b/pkg/query-service/app/logs/parser.go
@@ -23,6 +23,7 @@ var operatorMapping = map[string]string{
const (
AND = "and"
+ OR = "or"
ORDER = "order"
ORDER_BY = "orderBy"
TIMESTAMP_START = "timestampStart"
@@ -168,7 +169,7 @@ func parseLogQuery(query string) ([]string, error) {
operatorRemovedTokens := strings.Split(operatorRegex.ReplaceAllString(v, " "), " ")
searchCol := strings.ToLower(operatorRemovedTokens[0])
- if searchCol == AND {
+ if searchCol == AND || searchCol == OR {
searchCol = strings.ToLower(operatorRemovedTokens[1])
}
col := searchCol
@@ -179,6 +180,8 @@ func parseLogQuery(query string) ([]string, error) {
f := fmt.Sprintf(`%s %s '%%%s%%' `, col, operatorMapping[opLower], searchString[1:len(searchString)-1])
if strings.HasPrefix(strings.ToLower(v), AND) {
f = "AND " + f
+ } else if strings.HasPrefix(strings.ToLower(v), OR) {
+ f = "OR " + f
}
sqlQueryTokens = append(sqlQueryTokens, f)
} else {
diff --git a/pkg/query-service/app/logs/parser_test.go b/pkg/query-service/app/logs/parser_test.go
index 819f9d0c9e..cf8d12a803 100644
--- a/pkg/query-service/app/logs/parser_test.go
+++ b/pkg/query-service/app/logs/parser_test.go
@@ -37,6 +37,11 @@ var correctQueriesTest = []struct {
`resource contains 'Hello, "World"' and myresource contains 'abcd'`,
[]string{`resource ILIKE '%Hello, "World"%' `, `AND myresource ILIKE '%abcd%' `},
},
+ {
+ "contains with or",
+ `id in ('2CkBCauK8m3nkyKR19YhCw6WbdY') or fulltext contains 'OPTIONS /api/v1/logs'`,
+ []string{`id IN ('2CkBCauK8m3nkyKR19YhCw6WbdY') `, `OR body ILIKE '%OPTIONS /api/v1/logs%' `},
+ },
{
`filters with lt,gt,lte,gte operators`,
`id lt 100 and id gt 50 and code lte 500 and code gte 400`,