Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix unchecked stream_id #33335

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions x-pack/libbeat/management/generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,8 +170,8 @@ func injectStreamProcessors(expected *proto.UnitExpectedConfig, inputType string
// the AST injects input_id at the input level and not the stream level,
// for reasons I can't understand, as it just ends up shuffling it around
// to individual metricsets anyway, at least on metricbeat
if expected.GetId() != "" {
inputId := generateAddFieldsProcessor(mapstr.M{"input_id": expected.Id}, "@metadata")
if expectedID := expected.GetId(); expectedID != "" {
inputId := generateAddFieldsProcessor(mapstr.M{"input_id": expectedID}, "@metadata")
processors = append(processors, inputId)
}

Expand All @@ -191,9 +191,10 @@ func injectStreamProcessors(expected *proto.UnitExpectedConfig, inputType string
processors = append(processors, event)

// source stream
streamID := streamExpected.GetId()
sourceStream := generateAddFieldsProcessor(mapstr.M{"stream_id": streamID}, "@metadata")
processors = append(processors, sourceStream)
if streamID := streamExpected.GetId(); streamID != "" {
sourceStream := generateAddFieldsProcessor(mapstr.M{"stream_id": streamID}, "@metadata")
processors = append(processors, sourceStream)
}

// figure out if we have any existing processors
currentProcs, ok := stream["processors"]
Expand Down