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.

fix: JSON Query parse string int value (#8292)

Piyush Singariya3fc8f6c353c2
diff --git a/pkg/query-service/app/logs/v3/enrich_query.go b/pkg/query-service/app/logs/v3/enrich_query.go
index f4bfd8ba95..0ec2800ad9 100644
--- a/pkg/query-service/app/logs/v3/enrich_query.go
+++ b/pkg/query-service/app/logs/v3/enrich_query.go
@@ -217,7 +217,6 @@ func jsonReplaceField(filter v3.FilterItem, fields map[string]v3.AttributeKey) v
}
func parseStrValue(valueStr string, operator v3.FilterOperator) (string, interface{}) {
-
valueType := "string"
// for the following operators it will always be string
@@ -229,12 +228,12 @@ func parseStrValue(valueStr string, operator v3.FilterOperator) (string, interfa
var err error
var parsedValue interface{}
- if parsedValue, err = strconv.ParseBool(valueStr); err == nil {
- valueType = "bool"
- } else if parsedValue, err = strconv.ParseInt(valueStr, 10, 64); err == nil {
+ if parsedValue, err = strconv.ParseInt(valueStr, 10, 64); err == nil {
valueType = "int64"
} else if parsedValue, err = strconv.ParseFloat(valueStr, 64); err == nil {
valueType = "float64"
+ } else if parsedValue, err = strconv.ParseBool(valueStr); err == nil {
+ valueType = "bool"
} else {
parsedValue = valueStr
valueType = "string"
diff --git a/pkg/query-service/app/logs/v3/enrich_query_test.go b/pkg/query-service/app/logs/v3/enrich_query_test.go
index bea0c8b29f..2cc11b281c 100644
--- a/pkg/query-service/app/logs/v3/enrich_query_test.go
+++ b/pkg/query-service/app/logs/v3/enrich_query_test.go
@@ -519,6 +519,28 @@ var testJSONFilterEnrichData = []struct {
Value: 10,
},
},
+ {
+ Name: "int64 string",
+ Filter: v3.FilterItem{
+ Key: v3.AttributeKey{
+ Key: "body.intx",
+ DataType: v3.AttributeKeyDataTypeUnspecified,
+ Type: v3.AttributeKeyTypeUnspecified,
+ },
+ Operator: "=",
+ Value: "0",
+ },
+ Result: v3.FilterItem{
+ Key: v3.AttributeKey{
+ Key: "body.intx",
+ DataType: v3.AttributeKeyDataTypeInt64,
+ Type: v3.AttributeKeyTypeUnspecified,
+ IsJSON: true,
+ },
+ Operator: "=",
+ Value: int64(0),
+ },
+ },
{
Name: "float64",
Filter: v3.FilterItem{