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

Cherry-pick #9251 to 6.x: Log dropped events at the debug level #9324

Merged
merged 2 commits into from
Dec 6, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
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 @@ -38,6 +38,7 @@ https://github.com/elastic/beats/compare/v6.5.0...6.x[Check the HEAD diff]
*Affecting all Beats*

- Propagate Sync error when running SafeFileRotate. {pull}9069[9069]
- Log events at the debug level when dropped by encoding problems. {pull}9251[9251]

*Auditbeat*

Expand Down
1 change: 1 addition & 0 deletions libbeat/outputs/console/console.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ func (c *console) publishEvent(event *publisher.Event) bool {
}

logp.Critical("Unable to encode event: %v", err)
logp.Debug("console", "Failed event: %v", event)
return false
}

Expand Down
1 change: 1 addition & 0 deletions libbeat/outputs/elasticsearch/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,7 @@ func bulkEncodePublishRequest(
}
if err := body.Add(meta, event); err != nil {
logp.Err("Failed to encode event: %s", err)
logp.Debug("elasticsearch", "Failed event: %v", event)
continue
}
okEvents = append(okEvents, data[i])
Expand Down
1 change: 1 addition & 0 deletions libbeat/outputs/fileout/file.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ func (out *fileOutput) Publish(
} else {
logp.Warn("Failed to serialize the event: %v", err)
}
logp.Debug("file", "Failed event: %v", event)

dropped++
continue
Expand Down
1 change: 1 addition & 0 deletions libbeat/outputs/kafka/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ func (c *client) getEventMessage(data *publisher.Event) (*message, error) {

serializedEvent, err := c.codec.Encode(c.index, event)
if err != nil {
logp.Debug("kafka", "Failed event: %v", event)
return nil, err
}

Expand Down
8 changes: 6 additions & 2 deletions libbeat/outputs/logstash/enc.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,11 @@ import (

func makeLogstashEventEncoder(info beat.Info, escapeHTML bool, index string) func(interface{}) ([]byte, error) {
enc := json.New(false, escapeHTML, info.Version)
return func(event interface{}) ([]byte, error) {
return enc.Encode(index, event.(*beat.Event))
return func(event interface{}) (d []byte, err error) {
d, err = enc.Encode(index, event.(*beat.Event))
if err != nil {
debugf("Failed to encode event: %v", event)
}
return
}
}
2 changes: 2 additions & 0 deletions libbeat/outputs/redis/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,7 @@ func serializeEvents(
serializedEvent, err := codec.Encode(index, &d.Content)
if err != nil {
logp.Err("Encoding event failed with error: %v", err)
logp.Debug("redis", "Failed event: %v", d.Content)
goto failLoop
}

Expand All @@ -329,6 +330,7 @@ failLoop:
serializedEvent, err := codec.Encode(index, &d.Content)
if err != nil {
logp.Err("Encoding event failed with error: %v", err)
logp.Debug("redis", "Failed event: %v", d.Content)
i++
continue
}
Expand Down