-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
Add decode base64 field processor #11914
Conversation
Since this is a community submitted pull request, a Jenkins build has not been kicked off automatically. Can an Elastic organization member please verify the contents of this patch and then kick off a build manually? |
jenkins test this |
jenkins test this please |
3db61ae
to
4f32f09
Compare
|
||
func (f *decodeBase64Fields) Run(event *beat.Event) (*beat.Event, error) { | ||
data, err := event.GetValue(f.field) | ||
if err != nil && errors.Cause(err) != common.ErrKeyNotFound { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would be good to make this configurable, just like in case of other processors. By adding fail_on_error
and ignore_missing
users could eliminate flooding the logs of Beats if the keys are not present in the event. See the implementation in rename
processor: https://github.com/elastic/beats/blob/master/libbeat/processors/actions/rename.go#L36
0c1de6a
to
c864d5f
Compare
c864d5f
to
814bd5d
Compare
the code looks good, I am just worried about the usage and the configuration. The current code can work with a single instance of a processors on multiple fields. I wonder if it's better to make it a 1:1 mapping, each field need to define his own processors. I am thinking about this because the errors handling looks stranges when it's applied on multiple fields. @kvch in your comments #11914 (comment) were you asking only to add errors handling to the processors or allow a single processor to operate on multiple fields? |
So true. This really complicates things in other processors and I think having a 1:1 relationship like Ingest Node has would simplify many things. |
@mmatur Can you please also register this with the script processor so that it can be used there as well. Just need to add a line here:
|
3f47bff
to
4021509
Compare
@ph Yes, I would let one base64 processor work on multiple fields as in case of other processors. I think confusion around which field lead to an error can be avoided by adding the key name to the error message. WDYT? |
4021509
to
ddb04c9
Compare
@kvch @ph @andrewkroh do I need to keep 1:1 mapping? |
Keep it please. |
Thanks @kvch. My PR seems to be ready ;) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Almost there 👍 , just added a note for the documentation and a behavior changes when a type assertion fails.
Jenkins test this please |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you!
Jenkins test this |
@kvch I've retriggerred jenkins build just to make sure. |
Thanks @mmatur for adding this :) |
Description
This PR adds a new processor to be able to decode base64.
The
decode_base64_field
processor decodes field containing Base64 strings.The
decode_base64_field
processor has the following configuration settings:field
:: The field containing Base64 strings to decode.target
:: (Optional) The field under which the decoded Base64 will be written. Bydefault the decoded Base64 object replaces the string field from which it was
read.
target
with an empty string (target: ""
). Note that thenull
value (target:
)is treated as if the field was not set at all.