# Help, Cannot get multiline to work correctly

**URL:** <https://discuss.elastic.co/t/help-cannot-get-multiline-to-work-correctly/244161>\
**Category:** Beats\
**Tags:** filebeat\
**Created:** [August 7, 2020, 11:08am UTC](https://discuss.elastic.co/t/help-cannot-get-multiline-to-work-correctly/244161 "2020-08-07T11:08:04Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![calanon](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/calanon/32/64004_2.png) [@calanon](https://discuss.elastic.co/u/calanon)\
**Post date:** [August 7, 2020, 11:08am UTC](https://discuss.elastic.co/t/help-cannot-get-multiline-to-work-correctly/244161/1 "2020-08-07T11:08:04Z")

</div>

**I have this raw log output:**

```
[2020-08-07T12:45:33+02:00] 10.8.0.84 ERROR Exception: <log:context>{"exception":"[object] (UnexpectedValueException(code: 0): This is to simulate uncaught exceptions at /home/app1/products/services/lvs-api/releases/2.3.5/src/App/Action/StatusAction.php:29)
[stacktrace]
#0 /home/app1/products/services/lvs-api/releases/2.3.5/vendor/zendframework/zend-expressive/src/Middleware/LazyLoadingMiddleware.php(80): App\\Action\\StatusAction->__invoke(Object(Zend\\Diactoros\\ServerRequest), Object(Zend\\Diactoros\\Response), Object(Closure))
#1 /home/app1/products/services/lvs-api/releases/2.3.5/vendor/zendframework/zend-expressive/src/Middleware/DispatchMiddleware.php(90): Zend\\Expressive\\Middleware\\LazyLoadingMiddleware->process(Object(Zend\\Diactoros\\ServerRequest), Object(Zend\\Stratigility\\Next))

```

**This is the multiline pattern that I use to trap the first line of the message:**

`^\[\d+|^\d{4}\/\d{2}\/\d{2}`

**These are the settings for multiline in filebeat:**

```
  multiline.pattern: ^\[\d+|^\d{4}\/\d{2}\/\d{2} 
  multiline.negate: True
  multiline.match: after

```

According to my regex it will trap the line that starts with:

`[2020`

**What is actually happening:**

The message is being split up into multiple messages like so:

log message-1: [2020-08-07T12:45:33+02:00] 10.8.0.84 E  
log message-2: [stacktrace]  
log message-3: #0 /home/app1/pr  
log message-4: #1 /home/app1/pr

json output also confirms this.

Can anyone advise how I can fix this?

---

<div class="post-metadata">

**Author:** ![sai\_kiran1](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/sai_kiran1/32/44118_2.png) [@sai\_kiran1](https://discuss.elastic.co/u/sai_kiran1)\
**Post date:** [August 9, 2020, 9:00am UTC](https://discuss.elastic.co/t/help-cannot-get-multiline-to-work-correctly/244161/2 "2020-08-09T09:00:36Z")

</div>

This worked for me for the same log format..

multiline.pattern: ^[[0-9]{2,4}-[0-9]{1,2}-[0-9]{1,2}  
multiline.negate: True  
multiline.match: after

Regards,  
Sai

---

<div class="post-metadata">

**Author:** ![calanon](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/calanon/32/64004_2.png) [@calanon](https://discuss.elastic.co/u/calanon)\
**Post date:** [August 9, 2020, 11:30am UTC](https://discuss.elastic.co/t/help-cannot-get-multiline-to-work-correctly/244161/3 "2020-08-09T11:30:44Z")

</div>

Thanks Sai, I will give this a try.

---

<div class="post-metadata">

**Author:** ![calanon](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/calanon/32/64004_2.png) [@calanon](https://discuss.elastic.co/u/calanon)\
**Post date:** [August 9, 2020, 7:13pm UTC](https://discuss.elastic.co/t/help-cannot-get-multiline-to-work-correctly/244161/4 "2020-08-09T19:13:48Z")

</div>

> [@sai\_kiran1](#):
>
> ^[[0-9]{2,4}-[0-9]{1,2}-[0-9]{1,2}

Not sure whats going on, but I applied your suggestion. When I view the output in Kibana the messages are still split.

---

<div class="post-metadata">

**Author:** ![calanon](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/calanon/32/64004_2.png) [@calanon](https://discuss.elastic.co/u/calanon)\
**Post date:** [August 10, 2020, 7:08am UTC](https://discuss.elastic.co/t/help-cannot-get-multiline-to-work-correctly/244161/5 "2020-08-10T07:08:26Z")

</div>

> [@sai\_kiran1](#):
>
> ^[[0-9]{2,4}-[0-9]{1,2}-[0-9]{1,2}

Actually I looked at the regex again, shouldn't the first character be escaped [

---

<div class="post-metadata">

**Author:** ![sai\_kiran1](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/sai_kiran1/32/44118_2.png) [@sai\_kiran1](https://discuss.elastic.co/u/sai_kiran1)\
**Post date:** [August 11, 2020, 7:36am UTC](https://discuss.elastic.co/t/help-cannot-get-multiline-to-work-correctly/244161/6 "2020-08-11T07:36:20Z")

</div>

Indeed I somehow missed adding / 😅.

---

<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 8, 2020, 9:36am UTC](https://discuss.elastic.co/t/help-cannot-get-multiline-to-work-correctly/244161/7 "2020-09-08T09:36:21Z")

</div>

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