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

Decouple debug logging behaviour from fail_on_error value #12451

Closed
wants to merge 4 commits into from
Closed

Decouple debug logging behaviour from fail_on_error value #12451

wants to merge 4 commits into from

Conversation

AndyHunt66
Copy link
Contributor

@AndyHunt66 AndyHunt66 commented Jun 5, 2019

When using the rename, copy_fields or truncate_fields processors, and specifying multiple fields to be processed

  • if the processor fails on one of the fields (usually because a field is not present), a Debug log message will only be thrown if fail_on_error is true .

Logging of the error should be independent of the fail_on_error flag.

@AndyHunt66 AndyHunt66 requested a review from jsoriano June 5, 2019 16:53
@AndyHunt66 AndyHunt66 requested a review from a team as a code owner June 5, 2019 16:53
@@ -76,12 +76,14 @@ 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 && f.config.FailOnError {
if err != nil {
errMsg := fmt.Errorf("Failed to rename fields in processor: %s", err)
logp.Debug("rename", errMsg.Error())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is keeping this debug log necessary when the same message is logged on error level?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Part of the wider problem is that the message is not "logged on error level".
This whole issue only arose because there was no "failure to rename" error thrown unless you were running at debug.

IMHO this Debug should actually be Error

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I saw the issue you have opened. With this change, an error is logged, as we agreed previously. I asked the question because I think it is unnecessary to log the same error on both Debug and Error level when fail_on_error is set.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Then I think I'm misunderstanding you completely - my apologies.
I think I misunderstood what you meant by logging.
There is no "Error level" logging to the log file going on at all - either before or after this fix.
There is an error message inserted into the event itself (and thus ES), fail_on_error is true

Assuming an error condition, with this fix, the following behaviour happens

fail_on_error Log level Message in log file Message in event/ES
true default No Yes
true debug Yes Yes
false default No No
false debug Yes No

Which, I think is what you are both @kvch and @ruflin asking for?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is exactly what I've asked for. Thank you for the clear explanation. :)

Copy link
Contributor

@ruflin ruflin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The error is not logged when fail_on_error is false to prevent flooding the log message. We could still log something on debug level if it fails but we should not log it on the error level as through the config the user defined, that this is not an error.

@ruflin
Copy link
Contributor

ruflin commented Jun 7, 2019

@AndyHunt66 Thanks for your additional comment. I think I misread initially on what you wanted to do in this PR. Re-reading the PR (code) I know get the following:

  • Before this PR, when fail_on_error was false, it would not log anything on the debug level. With this change, it will but all the old behaviour stays the same.

Sorry for the initial confusion. Could you perhaps update the PR description to clarify this more (we only talk about debug log level changes) and also add, that you not only change the rename processor?

Could you add a changelog entry?

@AndyHunt66 AndyHunt66 changed the title Change logging behaviour with renameFields Decouple debug logging behaviour from fail_on_error value Jun 7, 2019
@AndyHunt66
Copy link
Contributor Author

AndyHunt66 commented Jun 7, 2019

@ruflin - Thanks - done : commit 4f59679

Edit: that didn't actually work out too well - apologies for the commit spaghetti
I've actually made a complete pigs ear of this.
The full fix and changelog is now all sorted in 23e59ef , but is not being referenced by this PR.

Please advise on how you would like me to resolve this. The cleanest way that I can see is to simply create a new PR .

@ruflin
Copy link
Contributor

ruflin commented Jun 11, 2019

Strangely above it shows "unkown repository" and is probably the reason the commit does not show up. Did you remove your clone, delete the branch or something like that?

If we find an easy option to revive this PR, great (for push is an option from my perspective), if not, please open a new PR and reference this one there.

@AndyHunt66
Copy link
Contributor Author

AndyHunt66 commented Jun 11, 2019

delete the branch or something like that?

Yes - exactly that. Sorry, my git skills are .... er... still growing.

I've created PR #12496 - will close this. Apologies for the messing around

@AndyHunt66 AndyHunt66 closed this Jun 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants