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.
TypeScript apmapplication-monitoringdistributed-tracinggogood-first-issuejaegerloglogsmetricsmonitoringnextjsobservabilityopen-sourceopentelemetryprometheusreactreactjsself-hostedtracingtypescript
fix: add missing filtering for ip address for scalar data (#10264)
Nikhil Soni1a5d37b25ad3
diff --git a/pkg/modules/thirdpartyapi/translator.go b/pkg/modules/thirdpartyapi/translator.goindex f92399864e..6780009321 100644--- a/pkg/modules/thirdpartyapi/translator.go+++ b/pkg/modules/thirdpartyapi/translator.go@@ -120,6 +120,8 @@ func FilterResponse(results []*qbtypes.QueryRangeResponse) []*qbtypes.QueryRange}}resultData.Rows = filteredRows+ case *qbtypes.ScalarData:+ resultData.Data = filterScalarDataIPs(resultData.Columns, resultData.Data)}filteredData = append(filteredData, result)@@ -145,6 +147,39 @@ func shouldIncludeSeries(series *qbtypes.TimeSeries) bool {return true}+func filterScalarDataIPs(columns []*qbtypes.ColumnDescriptor, data [][]any) [][]any {+ // Find column indices for server address fields+ serverColIndices := make([]int, 0)+ for i, col := range columns {+ if col.Name == derivedKeyHTTPHost {+ serverColIndices = append(serverColIndices, i)+ }+ }++ if len(serverColIndices) == 0 {+ return data+ }++ filtered := make([][]any, 0, len(data))+ for _, row := range data {+ includeRow := true+ for _, colIdx := range serverColIndices {+ if colIdx < len(row) {+ if strVal, ok := row[colIdx].(string); ok {+ if net.ParseIP(strVal) != nil {+ includeRow = false+ break+ }+ }+ }+ }+ if includeRow {+ filtered = append(filtered, row)+ }+ }+ return filtered+}+func shouldIncludeRow(row *qbtypes.RawRow) bool {if row.Data != nil {if domainVal, ok := row.Data[derivedKeyHTTPHost]; ok {diff --git a/pkg/modules/thirdpartyapi/translator_test.go b/pkg/modules/thirdpartyapi/translator_test.goindex 29edb6e59a..82e32e06c4 100644--- a/pkg/modules/thirdpartyapi/translator_test.go+++ b/pkg/modules/thirdpartyapi/translator_test.go@@ -117,6 +117,59 @@ func TestFilterResponse(t *testing.T) {},},},+ {+ name: "should filter out IP addresses from scalar data",+ input: []*qbtypes.QueryRangeResponse{+ {+ Data: qbtypes.QueryData{+ Results: []any{+ &qbtypes.ScalarData{+ QueryName: "endpoints",+ Columns: []*qbtypes.ColumnDescriptor{+ {+ TelemetryFieldKey: telemetrytypes.TelemetryFieldKey{Name: derivedKeyHTTPHost},+ Type: qbtypes.ColumnTypeGroup,+ },+ {+ TelemetryFieldKey: telemetrytypes.TelemetryFieldKey{Name: "endpoints"},+ Type: qbtypes.ColumnTypeAggregation,+ },+ },+ Data: [][]any{+ {"192.168.1.1", 10},+ {"example.com", 20},+ {"10.0.0.1", 5},+ },+ },+ },+ },+ },+ },+ expected: []*qbtypes.QueryRangeResponse{+ {+ Data: qbtypes.QueryData{+ Results: []any{+ &qbtypes.ScalarData{+ QueryName: "endpoints",+ Columns: []*qbtypes.ColumnDescriptor{+ {+ TelemetryFieldKey: telemetrytypes.TelemetryFieldKey{Name: derivedKeyHTTPHost},+ Type: qbtypes.ColumnTypeGroup,+ },+ {+ TelemetryFieldKey: telemetrytypes.TelemetryFieldKey{Name: "endpoints"},+ Type: qbtypes.ColumnTypeAggregation,+ },+ },+ Data: [][]any{+ {"example.com", 20},+ },+ },+ },+ },+ },+ },+ },}for _, tt := range tests {