The full pipeline config that manipulates the data is here:
if [question] {
ruby {
code => '
data = event.get("question")
if data.is_a? Array
newData = []
data.each { |h|
q = h.delete("questionid")
event.set("question#{q}", h)
}
end
'
}
ruby {
code => '
def EmptyField(object, name, event)
if object
if object.kind_of?(Hash) and object != {}
object.each { |k, v| EmptyField(v, "#{name}[#{k}]", event) }
elsif object.kind_of?(Array) and object != []
object.each_index { |i|
EmptyField(object[i], "#{name}[#{i}]", event)
}
else
if object == "nil"
event.remove(name)
end
end
end
end
event.to_hash.each { |k, v|
EmptyField(v, "[#{k}]", event)
}
'
}
split {
field => "question"
}
mutate {
remove_field => [ "[question]" ]
}
}