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

[8.5](backport #33837) filebeat/input/{tcp,udp}: don't panic on nil addresses #33850

Merged
merged 1 commit into from
Nov 29, 2022
Merged
Show file tree
Hide file tree
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
6 changes: 6 additions & 0 deletions CHANGELOG.next.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,12 @@ https://github.com/elastic/beats/compare/v8.2.0\...main[Check the HEAD diff]
*Heartbeat*

- Fix broken zip URL monitors. NOTE: Zip URL Monitors will be removed in version 8.7 and replaced with project monitors. {pull}33723[33723]
- Fix bug affecting let's encrypt and other users of cross-signed certs, where cert expiration was incorrectly calculated. {issue}33215[33215]
- Fix broken disable feature for kibana configured monitors. {pull}33293[33293]
- Fix states client support for output options. {pull}33405[33405]
- Fix states client reloader under managed mode. {pull}33405[33405]
- Fix bug where states.duration_ms was incorrect type. {pull}33563[33563]
- Fix handling of long UDP messages in UDP input. {issue}33836[33836] {pull}33837[33837]

*Auditbeat*

Expand Down
17 changes: 10 additions & 7 deletions filebeat/input/tcp/input.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ func NewInput(

cb := func(data []byte, metadata inputsource.NetworkMetadata) {
event := createEvent(data, metadata)
forwarder.Send(event)
_ = forwarder.Send(event)
}

splitFunc, err := streaming.SplitFunc(config.Framing, []byte(config.LineDelimiter))
Expand Down Expand Up @@ -128,15 +128,18 @@ func (p *Input) Wait() {
}

func createEvent(raw []byte, metadata inputsource.NetworkMetadata) beat.Event {
return beat.Event{
evt := beat.Event{
Timestamp: time.Now(),
Fields: mapstr.M{
"message": string(raw),
"log": mapstr.M{
"source": mapstr.M{
"address": metadata.RemoteAddr.String(),
},
},
},
}
if metadata.RemoteAddr != nil {
evt.Fields["log"] = mapstr.M{
"source": mapstr.M{
"address": metadata.RemoteAddr.String(),
},
}
}
return evt
}
17 changes: 10 additions & 7 deletions filebeat/input/udp/input.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,20 +65,23 @@ func NewInput(

forwarder := harvester.NewForwarder(out)
callback := func(data []byte, metadata inputsource.NetworkMetadata) {
forwarder.Send(beat.Event{
evt := beat.Event{
Timestamp: time.Now(),
Meta: mapstr.M{
"truncated": metadata.Truncated,
},
Fields: mapstr.M{
"message": string(data),
"log": mapstr.M{
"source": mapstr.M{
"address": metadata.RemoteAddr.String(),
},
},
},
})
}
if metadata.RemoteAddr != nil {
evt.Fields["log"] = mapstr.M{
"source": mapstr.M{
"address": metadata.RemoteAddr.String(),
},
}
}
_ = forwarder.Send(evt)
}

udp := udp.New(&config.Config, callback)
Expand Down