I've been struugling with this for far too long and I'm giving up and asking for help. I am being sent data via a Kafka topic which contains a field called 'headers' which is a CSV string of column headers, and a field called 'data' which is a CSV string of the corresponding data. What I want to achieve is to be able to use the header string as the 'columns' option is a CSV filter.
I am trying to use this but so far unsuccessfully:
csv {
source => "Data"
columns => "%{Headers}"
target => "data"
}
I have tried using,
mutate {
split => { "headers" => ","}
}
first, to create an array of headers, but this doesn't seem to work either as in the output I end up with 2 arrays, one of headers:
"Headers" => [
[ 0] "serverIP",
[ 1] "statsType",
[ 2] "adjacencyName",
[ 3] "adjStatAccountName",
[ 4] "adjStatSrcActiveCalls",
[ 5] "adjStatDstActiveCalls",
[ 6] "adjStatSrcActivatingCalls"
]
and one for the data:
"data" => [
"column168" => "0",
"column245" => "0",
"column18" => "0",
"column209" => "4294967295",
"column244" => "0",
"column153" => "0 / 10000 %"
]
In reality, the headers and corresponsing data strings have several hundred fields in them, so I don't really want to have to write them all out in the logstash filter.
Can anyone suggest a way that I can build the columns array in such a way that I can then pass it to the CSV filter to be used so that I get a proper key => value pair result?