Logstash to convert all numeric field to float

Hi, I recently start to work on a JSON> logstash > influx pipeline , I wonder if there is a way to make logstash to read every numeric value from JSON into float and write them into Influx. For now, some of the fields are Integer and others are Float.

Thank you

You can convert every top level integer to a float using

    ruby {
        code => '
            event.to_hash.each { |k, v|
                if v.is_a? Integer
                    event.set(k, v.to_f)
                end
            }
        '
    }

That will not be limited that were parsed from the JSON.

Works like a charm, side note that this goes into filter{}

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