Hi Team,
I have three arrays created from xml in logstash
content.REFERENCE: [PXXXX, TECHNICAL_SUPPORT]
content.ROOT: [INTERNAL_PRODUCT_OR_APPLICATION, TOPICS]
I have to create a result array from above inputs
if root array has product then create array productid : [PXXXX],
if root array has topics then create array producttopic: [TECHNICAL_SUPPORT]
I created below code
ruby {
code => "
content_root = event.get('[content][ROOT]')
content_refkey = event.get('[content][REFERENCE]')
producttopics = []
productid = []
if content_root.is_a? Hash
i=0
content_root.each do |root|
if root == 'PRODUCT'
productid << content_refkey[i]
elsif root == 'TOPICS'
producttopics << content_refkey[i]
end
i=i+1
end
end
event.set('productid', productid)
event.set('producttopics', producttopics)
"
}
but its showing error as the input fields are not array type in logstash. those array automatically created by xml filter from xml source.
is it considering it as a string? Please let me know.
Thanks,
Disha