Skip to content

Commit

Permalink
Fix panic on Metricbeat filters
Browse files Browse the repository at this point in the history
`nil` can happen if the event is dropped by processors. Fixes elastic#4327.
  • Loading branch information
Tudor Golubenco committed May 16, 2017
1 parent a09c903 commit d37a052
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ https://github.com/elastic/beats/compare/v6.0.0-alpha1...master[Check the HEAD d
*Metricbeat*
- Fix a debug statement that said a module wrapper had stopped when it hadn't. {pull}4264[4264]
- Use MemAvailable value from /proc/meminfo on Linux 3.14. {pull}4316[4316]
- Fix panic when events were dropped by filters. {issue}4327[4327]

*Packetbeat*

Expand Down
9 changes: 6 additions & 3 deletions metricbeat/mb/module/wrapper.go
Original file line number Diff line number Diff line change
Expand Up @@ -340,10 +340,13 @@ func (r *eventReporter) ErrorWith(err error, meta common.MapStr) bool {
return false
}

if !writeEvent(r.done, r.out, event) {
return false
if event != nil { // event can be nil if it was dropped by processors
if !writeEvent(r.done, r.out, event) {
return false
}
r.msw.stats.events.Add(1)
}
r.msw.stats.events.Add(1)

return true
}

Expand Down

0 comments on commit d37a052

Please sign in to comment.