You will need ruby to iterate over the documents
xml { source => "message" target => "[@metadata][theXML]" xpath => { "/NewData/Data/@ID" => "DataID" } }
mutate { replace => { "DataID" => "%{[DataID][0]}" } }
ruby {
code => '
docs = event.get("[@metadata][theXML][Document]")
if docs.is_a? Array
docs.each { |x|
id = x["ID"]
text = x["Text"][0]
event.set("documentId#{id}", text)
}
end
'
}
will get you
"documentId1" => " Some text here \n ",
"DataID" => "1234",
"documentId2" => " \nSome Text here B \n ",
The metadata field looks like this:
"theXML" => {
"Document" => [
[0] {
"ID" => "1",
"Instructions" => "THIS",
"Description" => "XXX",
"Type" => "-1",
"Text" => [
[0] " Some text here \n "
]
},
[1] {
"ID" => "2",
"Instructions" => "THIS",
"Description" => "YYY",
"Type" => "-1",
"Text" => [
[0] " \nSome Text here B \n "
]
}
],
"Data" => [
[0] {
"Instructions" => "Only Here",
"Description" => "This is a sample",
"OtherInstructions" => "NONE",
"EntryDate" => [
[0] {
"CCYY" => [
[0] "2020"
],
"Day" => [
[0] "13"
],
"Month" => [
[0] "4"
]
}
],
"ID" => "1234",
"ClientConfig" => [
[0] {
"ClientSetting" => [
[0] {
"name" => "Some_Value1",
"content" => "true"
},
[1] {
"name" => "Some_Value2",
"content" => "true"
},
[2] {
"name" => "Some_Value3",
"content" => "true"
},
[3] {
"name" => "Some_Value4",
"content" => "true"
},
[4] {
"name" => "Some_Value5",
"content" => "true"
}
]
}
],
"OutDate" => [
[0] {
"CCYY" => [
[0] "2020"
],
"Day" => [
[0] "13"
],
"Month" => [
[0] "4"
]
}
],
"OtherID" => "48",
"Type" => "Inside"
}
]
}