I'm a total newbie to logstash and I'm trying to input an xml file filter through it and output a specific formatted JSON file
Here is an example of the xml
<?xml version="1.0" encoding="UTF-8" ?><apartmentFeed version="1.0" timestamp="20150827:17:19:06">
<apartment id="675">
<general>
<reference>000671</reference>
<name><![CDATA[Brunswick Centre]]>
</name>
</general>
</apartment>
<apartment id="1221">
<general>
<reference>001218</reference>
<name><![CDATA[Saint Luke's]]>
</name>
</general>
</apartment>
<apartment id="1222">
<general>
<reference>001219</reference>
<name><![CDATA[Southwood Abstract]]>
</name>
</general>
</apartment>
</apartmentFeed>
and here is my config file
input {
file {
path => "C:/logstash/myXML.xml"
start_position => "beginning"
}
}
filter { multiline {
pattern => "^\s|</apartment>|^[A-Za-z].*"
what => "previous"
}
xml {
store_xml => "false"
source => "message"
xpath => [
"/apartment/@id", "apartment_id",
"/apartment/reference/text()","apartment_txt"
]
}
}
output {
stdout { codec => rubydebug }
file {
codec => "json"
path => ["C:/logstash/temp.json"]
}
}
The output seem to be capturing the info I want but it also output a lot of rubbish that I don't need. I would like the final output to be like
{"appartment":[
{"id":"675", "reference":"000671"},
{"id":"1221", "reference":"001218"},
{"id":"1222", "reference":"001219"}
]}
How can I do this