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

Omit empty process field from syslog input #12700

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
1 change: 1 addition & 0 deletions CHANGELOG.next.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ https://github.com/elastic/beats/compare/v7.0.0-alpha2...master[Check the HEAD d
- Fix timezone offset parsing in system/syslog. {pull}12529[12529]
- When TLS is configured for the TCP input and a `certificate_authorities` is configured we now default to `required` for the `client_authentication`. {pull}12584[12584]
- Apply `max_message_size` to incoming message buffer. {pull}11966[11966]
- Syslog input will now omit the `process` object from events if it is empty. {pull}12700[12700]

*Heartbeat*

Expand Down
4 changes: 3 additions & 1 deletion filebeat/input/syslog/input.go
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,9 @@ func createEvent(ev *event, metadata inputsource.NetworkMetadata, timezone *time

f["syslog"] = syslog
f["event"] = event
f["process"] = process
if len(process) > 0 {
f["process"] = process
}

if ev.Sequence() != -1 {
f["event.sequence"] = ev.Sequence()
Expand Down
15 changes: 4 additions & 11 deletions filebeat/input/syslog/input_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,11 +110,8 @@ func TestPid(t *testing.T) {
m := dummyMetadata()
event := createEvent(e, m, time.Local, logp.NewLogger("syslog"))

v, err := event.GetValue("process")
if !assert.NoError(t, err) {
return
}
assert.Equal(t, common.MapStr{}, v)
_, err := event.GetValue("process")
assert.Equal(t, common.ErrKeyNotFound, err)
})
}

Expand Down Expand Up @@ -165,12 +162,8 @@ func TestProgram(t *testing.T) {
m := dummyMetadata()
event := createEvent(e, m, time.Local, logp.NewLogger("syslog"))

v, err := event.GetValue("process")
if !assert.NoError(t, err) {
return
}

assert.Equal(t, common.MapStr{}, v)
_, err := event.GetValue("process")
assert.Equal(t, common.ErrKeyNotFound, err)
})
}

Expand Down