I am new to logstash. I am trying push XML (generated as the output of http polling) in logstash. I want to have the XML elements attributes convert to json objects.I am using xpath for parsing xml data.But i am getting separate array of xpath fields insteda of array of objects.
My http response will be like this:
17AGFAM
Falmouth Harbor
P
CARB
AG
-4.0000
1
18
GPIDS
Iles Des Saintes
P
CARB
GP
0.0000
1
19
MQQMR
Le Marin
P
CARB
MQ
-4.0000
1
My logstach confi xml filter like this:
filter {
xml {
store_xml => "false"
source => "message"
target => "abc"
remove_field => ["message","http_poller_metadata","@version","@timestamp"]
xpath => [
"/ResListLocation/LocationList/Location/LocationId/text()", "id",
"/ResListLocation/LocationList/Location/Name/text()", "name",
"/ResListLocation/LocationList/Location/Code/text()", "code"
]
force_array => false
}
}
I am gertting output like this:
{
"_index": "logst41",
"_type": "port",
"_id": "AWUlK6ZzTgnFfJZNCIK6",
"_score": 1,
"_source": {
"code": [
"AGFAM",
"GRKAP",
"SIKOP",
"MEKOT"
],
"name": [
"Salem, Massachusetts",
"Bridgetown",
"Santa Marta",
"Tampa"
],
"id": [
"17",
"18",
"19",
"20"
]
}
}
But I am expecting output like this:
{
"_index": "logst41",
"_type": "port",
"_id": "AWUlK6ZzTgnFfJZNCIK6",
"_score": 1,
"_source": {
abc:[
{"code":"AGFAM", "name":"Salem, Massachusetts","id": "17"},
{"code":"GRKAP", "name":"Bridgetown","id": "18"},
{"code":"SIKOP", "name":"Santa Marta","id": "19"}
]
}
}