Hello,
I have to parse an XML file and extract certain variables from it. The parsing part is solved. And from the XML filter I get three variables in this way:
"DX_METERNAME" => [
[0] "DX_KILOM",
[1] "DX_KILOM",
[2] "DX_KILOM"
],
"DX_NEWREADING" => [
[0] "26680",
[1] "27818",
[2] "22026"
],
"DX_EXTERNAL_REFERENCE" => [
[0] "CRA20-2",
[1] "CRA62",
[2] "CRA66"
]
Now I want to save them in a CSV File with, obsiously three rows (this number may vary depending on the information in the XML). What I want is something like:
DX_KILOM, 26680, CRA20-2
DX_KILOM, 27818, CRA62
DX_KILOM, 22026, CRA66
But the output in the file is like (in one single line):
"[""DX_KILOM"", ""DX_KILOM"", ""DX_KILOM""]","[""CRA20-2"", ""CRA62"", ""CRA66""]","[""26680"", ""27818"", ""22026""]"
I have also tried using the join filter, but the result is more or less the same (everything in the same line):
"DX_KILOM,DX_KILOM,DX_KILOM","CRA20-2,CRA62,CRA66","26680,27818,22026"
Here is my code for the output (LOGSTASH Version 7.1):
output{
stdout{}
csv{
fields => ["DX_METERNAME", "DX_EXTERNAL_REFERENCE" , "DX_NEWREADING"]
path => "/output_path/output.csv"
csv_options => {
"write_headers" => true
"headers" =>["DX_METERNAME","DX_NEWREADING","DX_EXTERNAL_REFERENCE"]
"col_sep" => ","
}
}
}
Can anyone help me?
Thanks in advance.