# Multiline codec with file input

**URL:** <https://discuss.elastic.co/t/multiline-codec-with-file-input/132895>\
**Category:** Logstash\
**Created:** [May 22, 2018, 8:57pm UTC](https://discuss.elastic.co/t/multiline-codec-with-file-input/132895 "2018-05-22T20:57:45Z")\
**Posts on this page:** 6\
**Page:** 1

<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:** [May 22, 2018, 8:57pm UTC](https://discuss.elastic.co/t/multiline-codec-with-file-input/132895/1 "2018-05-22T20:57:46Z")

</div>

No, it's not the usual problem. Using 6.2.4 I have a file that contains

```auto
1
1

2
2

3

```

They really are blank lines.

```
# od -a bar.txt
0000000 1 nl 1 nl nl 2 nl 2 nl nl 3 nl

```

With a stdin input, a multiline codec chops it up just fine. Running

```auto
/usr/share/logstash/bin/logstash -e '
    input {
        stdin {
            codec => multiline { pattern => "^$" negate => true what => "previous" }
        }
    }
    output { stdout { codec => rubydebug } }' < bar.txt

```

Gets me

```auto
{
          "host" => "[...]",
      "@version" => "1",
          "tags" => [
        [0] "multiline"
    ],
    "@timestamp" => 2018-05-22T20:54:01.262Z,
       "message" => "\n2\n2"
}
{
          "host" => "[...]",
      "@version" => "1",
          "tags" => [
        [0] "multiline"
    ],
    "@timestamp" => 2018-05-22T20:54:01.260Z,
       "message" => "1\n1"
}

```

However using a file input

```auto
/usr/share/logstash/bin/logstash -e '
    input {
        file {
            path => "/path/to/bar.txt"
            codec => multiline { pattern => "^$" negate => true what => "previous" }
            start_position => "beginning"
            sincedb_path => "/dev/null"
        }
    }
    output { stdout { codec => rubydebug } }'

```

Gets me nothing until I SIGINT logstash, at which point it flushes the whole file, with the blank lines deleted.

```auto
{
      "@version" => "1",
          "path" => "/path/to/bar.txt",
    "@timestamp" => 2018-05-22T20:56:23.094Z,
          "tags" => [
        [0] "multiline"
    ],
       "message" => "1\n1\n2\n2\n3",
          "host" => "[...]"
}

```

auto\_flush\_interval does not fix anything, just saves me having to do the SIGINT. What am I missing?

---

<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:** [May 23, 2018, 5:33pm UTC](https://discuss.elastic.co/t/multiline-codec-with-file-input/132895/2 "2018-05-23T17:33:56Z")

</div>

Anyone?

---

<div class="post-metadata">

**Author:** ![sm00thindian](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/sm00thindian/32/27376_2.png) [@sm00thindian](https://discuss.elastic.co/u/sm00thindian)\
**Post date:** [May 24, 2018, 9:26am UTC](https://discuss.elastic.co/t/multiline-codec-with-file-input/132895/3 "2018-05-24T09:26:44Z")

</div>

Does the file have line terminators?

---

<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:** [May 24, 2018, 12:04pm UTC](https://discuss.elastic.co/t/multiline-codec-with-file-input/132895/4 "2018-05-24T12:04:33Z")

</div>

Yes, this is on Linux, so nl is the line terminator.

---

<div class="post-metadata">

**Author:** ![sm00thindian](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/sm00thindian/32/27376_2.png) [@sm00thindian](https://discuss.elastic.co/u/sm00thindian)\
**Post date:** [May 24, 2018, 12:55pm UTC](https://discuss.elastic.co/t/multiline-codec-with-file-input/132895/5 "2018-05-24T12:55:18Z")

</div>

If this is test environment try deleting data/registry and run again

---

<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:** [June 21, 2018, 12:55pm UTC](https://discuss.elastic.co/t/multiline-codec-with-file-input/132895/6 "2018-06-21T12:55:19Z")

</div>

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