Add an array in an array


(Joseph Martell) #1

Hello !

I'm working with the 5.6 elastic stack.
I would like to be able to include an array in an array when doing a add_field using Logstash.

mutate {
	add_field => {
		"weight" => [ [0.4, 0.6], [0.3, 0.8], [0.6, 0.95] ]
	}
}

The problem is that Logstash considers each entry as a string and I need it to be an array with floats.

"weight" => [
    [0] "[0.4, 0.6]",
    [1] "[0.3, 0.8]",
    [2] "[0.6, 0.95]"
]

I thought of converting weight into a float property - just in case - but then weight = 0.0.

How can I avoid the string conversion and keep float values ?

Regards,


(Magnus B├Ąck) #2

Logstash's configuration language is too limited for that. You'll have to use a ruby filter.


(Joseph Martell) #3

Thanks for the reply that confirms what I thought.

My knowledge in Ruby is quite rudimentary so I decided to change my ingest elastic plugin for it to cast the "String array" to a Java List.


(system) #4

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