I have a xml which looks like
<Countries><Country><Name>India</Name><ISDCode>+91</ISDCode><Continent>Asia</Continent><geolocationinfo><lattitude>123129</lattitude><longititude>7890890</longititude></geolocationinfo></Country><Country><Name>Srilanka</Name><ISDCode>+94</ISDCode><Continent>Asia</Continent><geolocationinfo><lattitude>1212349</lattitude><longititude>123890</longititude></geolocationinfo></Country></Countries>
All the content of the xml are in single line and we use filebeat to collect the data from log file and send it to logstash.
We need to store this xml as two document in Elasticsearch
doc1:
Name: India
ISDCode: +91
continent: Asia
geolocationinfo.Lattitude: 123129
geolocationinfo.longititude: 7890890
doc2:
Name: Srilanka
ISDCode: +94
continent: Asia
geolocationinfo.Lattitude: 1212349
geolocationinfo.longititude: 123890
Following is the logstash.conf that we have
input {
beats {
port => 5044
}
}
filter
{
xml
{
source => "message"
target => "xml_content"
store_xml => true
xpath =>
[
"/Countries/Country/Name/text()", "Name",
"/Countries/Country/ISDCode/text()", "ISDCode",
"/Countries/Country/Continent/text()", "Continent",
"/Countries/Country/geolocationinfo/lattitude/text()", "geolocationinfo.lattitude",
"/Countries/Country/geolocationinfo/longititude/text()", "geolocationinfo.longititude"
]
}
split{
field => 'Name'
}
}
}
output {
elasticsearch {
hosts => ["http://localhost:9200"]
index => "test"
}
}
What we get is two documents but the document contains only Name column and other columns are missing. I tried adding add_field also to split plugin but no luck.