Ruby filter - detect null values inside structure

In my Logstash pipeline, I am loading JSON messages and later use a ruby filter to detect and apply special logic to fields with null values.

ruby {
    code => "
    event.to_hash.each { |key,value|
        if value == nil
            //some logic here
        end
    }"
}

It works great when the field has a null value, but I would like to expand it to the situation when field is a structure and some of these structure fields have a null value. Also, the whole situation can be more nested: structure -> one of filed is nested structure -> inner field has null value.
What is the best approach to this challenge?

Use a script and iterate over the objects. Something like this or this.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.