Removing null fields from nexted fields - xml filter

im using the xml filter to parse xml with logstash. This places the xml info in a nested field, such as:
[entry][xmlField1]
[entry][xmlField2]

i am having issues with mappings and data when the fields are periodically null. I would like to try to remove the fields that are null, but the xml filter does not have anything which will do that (such as suppress_empty).

the following ruby code does not dig into nested fields and my ruby experience is slightly above 0.
ruby {
code => "
hash = event.to_hash
hash.each do |k,v|
if v == nil
event.remove(k)
end
end
"
}

Anyhow, im open to ideas.

Moving to logstash :slight_smile:

indeed, sorry!

I've used something like this before;

if [field] == "" {
    drop {}
  }

Won't that drop the entire entry, as opposed to just the field that is null? I would still like to keep the rest of the data in the entry.

Oh right, sorry.

Just remove_field then, with mutate.