mirror of
https://github.com/SigNoz/signoz.git
synced 2025-12-19 00:17:00 +00:00
Fix: Logs: Pipelines: add nil check for grok parser parseFrom field in generated collector config (#4286)
* chore: add test validating grok parser doesn't spam logs if parse from is missing * chore: add nil check for grok parser parseFrom
This commit is contained in:
parent
ec27916fa5
commit
bcd6ac47f7
@ -101,6 +101,15 @@ func getOperators(ops []PipelineOperator) ([]PipelineOperator, error) {
|
|||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
} else if operator.Type == "grok_parser" {
|
||||||
|
parseFromNotNilCheck, err := fieldNotNilCheck(operator.ParseFrom)
|
||||||
|
if err != nil {
|
||||||
|
return nil, fmt.Errorf(
|
||||||
|
"couldn't generate nil check for parseFrom of grok op %s: %w", operator.Name, err,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
operator.If = parseFromNotNilCheck
|
||||||
|
|
||||||
} else if operator.Type == "json_parser" {
|
} else if operator.Type == "json_parser" {
|
||||||
parseFromNotNilCheck, err := fieldNotNilCheck(operator.ParseFrom)
|
parseFromNotNilCheck, err := fieldNotNilCheck(operator.ParseFrom)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@ -386,8 +386,19 @@ func TestNoCollectorErrorsFromProcessorsForMismatchedLogs(t *testing.T) {
|
|||||||
makeTestLog("mismatching log", map[string]string{
|
makeTestLog("mismatching log", map[string]string{
|
||||||
"test_timestamp": "not-an-epoch",
|
"test_timestamp": "not-an-epoch",
|
||||||
}),
|
}),
|
||||||
|
}, {
|
||||||
|
"grok parser should ignore logs with missing parse from field",
|
||||||
|
PipelineOperator{
|
||||||
|
ID: "grok",
|
||||||
|
Type: "grok_parser",
|
||||||
|
Enabled: true,
|
||||||
|
Name: "grok parser",
|
||||||
|
ParseFrom: "attributes.test",
|
||||||
|
Pattern: "%{GREEDYDATA}",
|
||||||
|
ParseTo: "attributes.test_parsed",
|
||||||
|
},
|
||||||
|
makeTestLog("test log with missing parse from field", map[string]string{}),
|
||||||
},
|
},
|
||||||
// TODO(Raj): see if there is an error scenario for grok parser.
|
|
||||||
// TODO(Raj): see if there is an error scenario for trace parser.
|
// TODO(Raj): see if there is an error scenario for trace parser.
|
||||||
// TODO(Raj): see if there is an error scenario for Add operator.
|
// TODO(Raj): see if there is an error scenario for Add operator.
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user