Skip to content

Commit

Permalink
Merge pull request #900 from andrewkroh/bugfix/filebeat-null-fields
Browse files Browse the repository at this point in the history
Omit 'fields' from Filebeat events when null
  • Loading branch information
ruflin committed Feb 2, 2016
2 parents 26dcaa5 + 1bbe205 commit 307cd73
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 4 deletions.
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

0 comments on commit 307cd73

Please sign in to comment.