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 'fields' from Filebeat events when null #900

Merged
merged 1 commit into from
Feb 2, 2016
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.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ https://github.com/elastic/beats/compare/v1.1.0...master[Check the HEAD diff]
*Filebeat*
- Stop filebeat if filebeat is started without any prospectors defined or empty prospectors {pull}644[644] {pull}647[647]
- Improve shutdown of crawler and prospector to wait for clean completion {pull}720[720]
- Omit `fields` from Filebeat events when null {issue}899[899]

*Winlogbeat*

Expand Down
2 changes: 1 addition & 1 deletion filebeat/harvester/log.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ func (h *Harvester) Harvest() {
Offset: h.Offset,
Bytes: bytesRead,
Text: &text,
Fields: &h.Config.Fields,
Fields: h.Config.Fields,
Fileinfo: &info,
}

Expand Down
4 changes: 2 additions & 2 deletions filebeat/input/file.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ type FileEvent struct {
Offset int64
Bytes int
Text *string
Fields *common.MapStr
Fields common.MapStr
Fileinfo *os.FileInfo

fieldsUnderRoot bool
Expand Down Expand Up @@ -77,7 +77,7 @@ func (f *FileEvent) ToMapStr() common.MapStr {

if f.Fields != nil {
if f.fieldsUnderRoot {
for key, value := range *f.Fields {
for key, value := range f.Fields {
// in case of conflicts, overwrite
_, found := event[key]
if found {
Expand Down
2 changes: 1 addition & 1 deletion filebeat/input/file_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ func TestFileEventToMapStr(t *testing.T) {

func TestFieldsUnderRoot(t *testing.T) {
event := FileEvent{
Fields: &common.MapStr{
Fields: common.MapStr{
"hello": "world",
},
}
Expand Down
1 change: 1 addition & 0 deletions filebeat/tests/system/test_fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,3 +80,4 @@ def test_beat_fields(self):
doc = output[0]
assert doc["beat.name"] == "testShipperName"
assert doc["beat.hostname"] == socket.gethostname()
assert "fields" not in doc