if [dataflow] {
ruby {
code => '
event.get("dataflow").each { |item| ---> work till here, as I can print item which is whole array
index=1
event.get("item").each { |k, v|
event.set("dataflow_m#{index}_#{k}", v)
}
index += 1
}
'
}
}
something I am missing which is not creating new field.
I try this and divided this, as test and I got what I need. but I do not know how many array element will I have in dataflow, hence I can't delete them or run iterate on second for loop
any other recommendation?
#### this code is dividing array in to { key,value) pairs
ruby {
code => '
event.get("dataflow").each_with_index { |val,index |
event.set("whatisthis_#{index}", val)
}
'
}
### this one creating new field depending on key and value
ruby {
code => '
for i in 0..1
event.get("whatisthis_#{i}").each { |k, v|
event.set("dataflow_m#{i}_#{k}", v)
}
event.remove("whatisthis_#{i}")
end
'
}
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.