The CSV parser does not like the space after the separator.
aaa, "AB1\nCD2\nEF3\n"
^ space here
If all separators are followed by a space, use separator => ", " i.e. make the separator into comma space.
If not then use mutate gsub before with mutate { gsub => [ "message", ", \"", ",\""] }
Sorry, this was a typo in my question.
The actual input is aaa,"AB1\nCD2\nEF3\n"
An is also correct in the logstash rubydebug. "message" => "aaa,\"AB1\nCD2\nEF3\n\"",
There is no issue with the separator.
The issue is with \n in a quoted column.
I used the mutiline codec in the Logstash input file section to read the next line as a continuation of the previous:
# This says that any line not starting with a timestamp should be merged with the previous line.
codec => multiline {
# Grok pattern names are valid! :)
pattern => "^\d{4}[-]\d{2}[-]\d{2}"
negate => true
what => "previous"
auto_flush_interval => 5
}
Now I have the \n inside the double quotes.
CSV does not like it.
To keep moving I followed your advice about using gsub.
gsub matches a regular expression against a field value and replace all matches with a replacement string.
However,
the pattern you suggested "^±|±^" has two regular expression control characters ^ |
It does not work at the end gsub => [ "field2", "^±|±^", "\n"]
Nevertheless, I used an improbable pattern with no control characters.
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.