Skip to content

Commit

Permalink
Log event failed in the encoder
Browse files Browse the repository at this point in the history
  • Loading branch information
jsoriano committed Nov 27, 2018
1 parent c972608 commit 9748535
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
1 change: 0 additions & 1 deletion libbeat/outputs/logstash/async.go
Original file line number Diff line number Diff line change
Expand Up @@ -254,5 +254,4 @@ func (r *msgRef) dec() {

r.batch.RetryEvents(r.slice)
logp.Err("Failed to publish events caused by: %v", err)
logp.Debug("logstash", "Failed events: %v", r.slice)
}
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
}
}
1 change: 0 additions & 1 deletion libbeat/outputs/logstash/sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,6 @@ func (c *syncClient) Publish(batch publisher.Batch) error {
_ = c.Close()

logp.Err("Failed to publish events caused by: %v", err)
logp.Debug("logstash", "Failed events: %v", events)

rest := len(events)
st.Failed(rest)
Expand Down

0 comments on commit 9748535

Please sign in to comment.