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

Support dynamic target field names #30

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

magnusbaeck
Copy link
Contributor

It's conceivable that one would want the target field name to be chosen dynamically using the contents of another field, so pass the target option value through sprintf. Fixes #28.

Tests will fail until #29 is merged.

@@ -83,7 +83,7 @@ def filter(event)
end

if @target
event.set(@target, parsed)
event.set(event.sprintf(@target), parsed)
Copy link
Contributor

Choose a reason for hiding this comment

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

There's room for confusion here that a user may want a value from the parsed object to dictate what field is set. If we're going to allow this behavior, I think we need to document what does and doesn't work for this plugin. Thoughts?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point @jordansissel! I think it'd be nice to support pulling a field from the parsed object, but how would that addressing even work since we also need to support indirect addressing based on existing fields?

I'm leaning towards keeping the existing behavior but documenting it (I forgot about that in this first version of the patch). Selecting the target field based on fields from the parsed object is possible via an extra mutate operation afterwards so we won't be blocking anything with this limitation. Sounds good to you?

@steverice
Copy link

@magnusbaeck Are you still planning on moving ahead with this change? It appears that #29 has been merged and this would be a useful addition, even with the (to be documented) limitation.

@magnusbaeck
Copy link
Contributor Author

Are you still planning on moving ahead with this change?

Yes, I've just been too lazy to complete it. I'll try to get to it during the next couple of days.

It's conceivable that one would want the target field name to be
chosen dynamically using the contents of another field, so pass the
target option value through sprintf.
@magnusbaeck
Copy link
Contributor Author

@jordansissel, I've updated this PR and documented the behavior that you had a question about. Please have another look.

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.

allow json target to be dynamic
4 participants