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: logs pipelines: ensure special characters in pipeline identifiers don't result in bad collector config names (#6259)

Raj Kamal Singh94e0423479af
diff --git a/pkg/query-service/app/logparsingpipeline/collector_config_test.go b/pkg/query-service/app/logparsingpipeline/collector_config_test.go
index 5cc15b2aa2..1ddf092e9f 100644
--- a/pkg/query-service/app/logparsingpipeline/collector_config_test.go
+++ b/pkg/query-service/app/logparsingpipeline/collector_config_test.go
@@ -366,3 +366,65 @@ func TestPipelineRouterWorksEvenIfFirstOpIsDisabled(t *testing.T) {
}, result[0].Attributes_string,
)
}
+
+func TestPipeCharInAliasDoesntBreakCollectorConfig(t *testing.T) {
+ require := require.New(t)
+
+ testPipelines := []Pipeline{
+ {
+ OrderId: 1,
+ Name: "test | pipeline",
+ Alias: "test|pipeline",
+ Enabled: true,
+ Filter: &v3.FilterSet{
+ Operator: "AND",
+ Items: []v3.FilterItem{
+ {
+ Key: v3.AttributeKey{
+ Key: "method",
+ DataType: v3.AttributeKeyDataTypeString,
+ Type: v3.AttributeKeyTypeTag,
+ },
+ Operator: "=",
+ Value: "GET",
+ },
+ },
+ },
+ Config: []PipelineOperator{
+ {
+ OrderId: 1,
+ ID: "add",
+ Type: "add",
+ Field: "attributes.test",
+ Value: "val",
+ Enabled: true,
+ Name: "test add",
+ },
+ },
+ },
+ }
+
+ result, collectorWarnAndErrorLogs, err := SimulatePipelinesProcessing(
+ context.Background(),
+ testPipelines,
+ []model.SignozLog{
+ makeTestSignozLog(
+ "test log body",
+ map[string]any{
+ "method": "GET",
+ },
+ ),
+ },
+ )
+
+ require.Nil(err)
+ require.Equal(0, len(collectorWarnAndErrorLogs))
+ require.Equal(1, len(result))
+
+ require.Equal(
+ map[string]string{
+ "method": "GET",
+ "test": "val",
+ }, result[0].Attributes_string,
+ )
+}
diff --git a/pkg/query-service/app/logparsingpipeline/pipelineBuilder.go b/pkg/query-service/app/logparsingpipeline/pipelineBuilder.go
index 4f7963c10a..07a0ea6346 100644
--- a/pkg/query-service/app/logparsingpipeline/pipelineBuilder.go
+++ b/pkg/query-service/app/logparsingpipeline/pipelineBuilder.go
@@ -2,6 +2,7 @@ package logparsingpipeline
import (
"fmt"
+ "regexp"
"slices"
"strings"
@@ -17,8 +18,13 @@ const (
NOOP = "noop"
)
+// To ensure names used in generated collector config are never judged invalid,
+// only alphabets, digits and `-` are used when translating pipeline identifiers
+var badCharsForCollectorConfName = regexp.MustCompile("[^a-zA-Z0-9-]")
+
func CollectorConfProcessorName(p Pipeline) string {
- return constants.LogsPPLPfx + p.Alias
+ normalizedAlias := badCharsForCollectorConfName.ReplaceAllString(p.Alias, "-")
+ return constants.LogsPPLPfx + normalizedAlias
}
func PreparePipelineProcessor(pipelines []Pipeline) (map[string]interface{}, []string, error) {