# \[Multiline\]Data following newline is ignored

**URL:** <https://discuss.elastic.co/t/multiline-data-following-newline-is-ignored/193733>\
**Category:** Logstash\
**Created:** [August 5, 2019, 6:32am UTC](https://discuss.elastic.co/t/multiline-data-following-newline-is-ignored/193733 "2019-08-05T06:32:19Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sjaak01](https://avatars.discourse-cdn.com/v4/letter/s/73ab20/32.png) [@Sjaak01](https://discuss.elastic.co/u/Sjaak01)\
**Post date:** [August 5, 2019, 6:32am UTC](https://discuss.elastic.co/t/multiline-data-following-newline-is-ignored/193733/1 "2019-08-05T06:32:19Z")

</div>

Hi,

I have a csv file that contains a double quoted field with a empty line. I am trying to convert this to a single line using the multiline codec so I can filter it later on using the csv filter.

csv example

> number,Alarm,Date,Message,Details,group,id  
> 100,Warning,2019/12/01,some message. (something),"something, do this;
> 
> 1. do something.
> 2. something [something] something ""something"" something.
> 3. Do [something] for [something] something.
> 
> Status: something.",groupname,12345678

But for some reason everything after 3. is ignored and does not show up in the stdout. For testing purposes I removed the double quoted `""something""`.

config

```
 input {
  file {
   path => "Alarm.csv"
   sincedb_path => "/dev/null"
   start_position => "beginning"
   type => "me_alerts"
   codec => multiline {
     pattern => "\""
     negate => true
     what => previous
   }
 }
}

```

stdout

`"message" => "100,Warning,2019/12/01,some message. (something),\"something, do this;\n 1. do something.\n 2. something [something] something something something.\n 3. Do [something] for [something] something.",`

Everything after the empty line in the csv source field is dropped. Is there a way to solve this?

---

<div class="post-metadata">

**Author:** ![Badger](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/badger/32/25190_2.png) [@Badger](https://discuss.elastic.co/u/Badger)\
**Post date:** [August 5, 2019, 12:36pm UTC](https://discuss.elastic.co/t/multiline-data-following-newline-is-ignored/193733/2 "2019-08-05T12:36:57Z")

</div>

> [@Sjaak01](#):
>
> Is there a way to solve this?

I do not think so. The multiline filter is configured to say "if the line does not contain a double quote, then append it to the previous line". That results in the closing " being in a separate event. You would need a stateful approach that says "if I have seen an opening double quote then the next double quote that is not escaped with a second double quote is a closing double quote".

A codec that could handle that would be useful. There is a [csv codec](https://github.com/logstash-plugins/logstash-codec-csv) but I do not know if it handles this correctly.

---

<div class="post-metadata">

**Author:** ![Sjaak01](https://avatars.discourse-cdn.com/v4/letter/s/73ab20/32.png) [@Sjaak01](https://discuss.elastic.co/u/Sjaak01)\
**Post date:** [August 5, 2019, 11:38pm UTC](https://discuss.elastic.co/t/multiline-data-following-newline-is-ignored/193733/3 "2019-08-05T23:38:27Z")

</div>

The cvs filter doesn't handle the double quoted fields (exception errors) correctly hence I tried using the multiline codec.

But what I don't understand is why the multiline codec doesn't process the part after the new line. That line doesn't contain a double quote so why is it stopping there?

By the way, thinking about it, if I have multiple rows in the original csv, won't the multiline codec all stuff that together, creating problems further down the line if I where to apply the csv filter?

Maybe I'd be better off trying to make a script to "fix" the double quoted fields before ingesting the data with Logstash.

---

<div class="post-metadata">

**Author:** ![Badger](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/badger/32/25190_2.png) [@Badger](https://discuss.elastic.co/u/Badger)\
**Post date:** [August 6, 2019, 12:31am UTC](https://discuss.elastic.co/t/multiline-data-following-newline-is-ignored/193733/4 "2019-08-06T00:31:07Z")

</div>

> [@Sjaak01](#):
>
> Maybe I'd be better off trying to make a script to "fix" the double quoted fields before ingesting the data with Logstash.

I doubt it.

If someone held a gun to my head and told me to fix it I would look at writing a codec that could parse nested double quoted strings.

I am hoping nobody holds a gun to my head. It's hard, but not outrageous.

---

<div class="post-metadata">

**Author:** ![Sjaak01](https://avatars.discourse-cdn.com/v4/letter/s/73ab20/32.png) [@Sjaak01](https://discuss.elastic.co/u/Sjaak01)\
**Post date:** [August 6, 2019, 1:33am UTC](https://discuss.elastic.co/t/multiline-data-following-newline-is-ignored/193733/5 "2019-08-06T01:33:34Z")

</div>

If I only I knew how to program hehe.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [September 3, 2019, 1:37am UTC](https://discuss.elastic.co/t/multiline-data-following-newline-is-ignored/193733/6 "2019-09-03T01:37:51Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
