Skip to content

Commit

Permalink
Decouple debug logging behaviour from fail_on_error value
Browse files Browse the repository at this point in the history
  • Loading branch information
AndyHunt66 committed Jun 7, 2019
1 parent 764a008 commit 4f59679
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 17 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.next.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ https://github.com/elastic/beats/compare/v7.0.0-alpha2...master[Check the HEAD d

*Affecting all Beats*

- Decouple Debug logging from fail_on_error logic for rename, copy, truncate processors {pull}12451[12451]
- Add an option to append to existing logs rather than always rotate on start. {pull}11953[11953]
- Add `network` condition to processors for matching IP addresses against CIDRs. {pull}10743[10743]
- Add if/then/else support to processors. {pull}10744[10744]
Expand Down
10 changes: 4 additions & 6 deletions libbeat/processors/actions/copy_fields.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,14 +72,12 @@ func (f *copyFields) Run(event *beat.Event) (*beat.Event, error) {

for _, field := range f.config.Fields {
err := f.copyField(field.From, field.To, event.Fields)
if err != nil {
if err != nil && f.config.FailOnError {
errMsg := fmt.Errorf("Failed to copy fields in copy_fields processor: %s", err)
logp.Debug("copy_fields", errMsg.Error())
if f.config.FailOnError {
event.Fields = backup
event.PutValue("error.message", errMsg.Error())
return event, err
}
event.Fields = backup
event.PutValue("error.message", errMsg.Error())
return event, err
}
}

Expand Down
10 changes: 4 additions & 6 deletions libbeat/processors/actions/rename.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,14 +76,12 @@ func (f *renameFields) Run(event *beat.Event) (*beat.Event, error) {

for _, field := range f.config.Fields {
err := f.renameField(field.From, field.To, event.Fields)
if err != nil {
if err != nil && f.config.FailOnError {
errMsg := fmt.Errorf("Failed to rename fields in processor: %s", err)
logp.Debug("rename", errMsg.Error())
if f.config.FailOnError {
event.Fields = backup
event.PutValue("error.message", errMsg.Error())
return event, err
}
event.Fields = backup
event.PutValue("error.message", errMsg.Error())
return event, err
}
}

Expand Down
8 changes: 3 additions & 5 deletions libbeat/processors/actions/truncate_fields.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,12 +85,10 @@ func (f *truncateFields) Run(event *beat.Event) (*beat.Event, error) {

for _, field := range f.config.Fields {
event, err := f.truncateSingleField(field, event)
if err != nil {
if err != nil && f.config.FailOnError {
logp.Debug("truncate_fields", "Failed to truncate fields: %s", err)
if f.config.FailOnError {
event.Fields = backup
return event, err
}
event.Fields = backup
return event, err
}
}

Expand Down

0 comments on commit 4f59679

Please sign in to comment.