logstash-plugins / logstash-filter-mutate

Apache License 2.0
16 stars 75 forks source link

Feature: select - only keep the selected fields #9

Closed jrgns closed 9 years ago

jrgns commented 9 years ago

Allow a user to only keep the specified fields.

This is a nice feature for when an input like IMAP is used where a number of (sometimes) useless fields are added, and you don't want to list all the fields to remove. Specifically since you're not sure what those extra fields will always be.

Tests included.

jrgns commented 9 years ago

@ph Is there a way to get this merged? What's the policy / workflow?

jrgns commented 9 years ago

@ph @jordansissel Can we get this merged?

jrgns commented 9 years ago

@suyograo Done.

jrgns commented 9 years ago

@talevy I've refactored the feature. I believe this should address all of your comments.

jrgns commented 9 years ago

@purbon I've coded a workaround to ensure the timestamp and version isn't discarded.

I used overwrite for the following reasons:

If the core event can provide a method that handles those three cases, I can definitely use it.

talevy commented 9 years ago

I the intent to also support selecting specific values from arrays? if so, it would be awesome to see a test for selecting specific array elements!

jrgns commented 9 years ago

@talevy It certainly is. The test you suggested shows that more clearly. Added it and fixed the other issue as well.

jordansissel commented 9 years ago

Reading the subject of this PR alone "only keep the selected fields" - the prune filter can do this already, can't it?

talevy commented 9 years ago

indeed it can, thats the plugin I was looking for! for some reason I thought some of that functionality was in the base class, went looking for it, and couldn't find it. but prune definitely does it!

jrgns commented 9 years ago

@jordansissel Indeed it can. The remove feature can also be handled by that and the remove_field option, so it might make sense to it from here?

Closing this.