# Add field multiline under multiline filebeat/logstash

**URL:** <https://discuss.elastic.co/t/add-field-multiline-under-multiline-filebeat-logstash/297765>\
**Category:** Logstash\
**Created:** [February 21, 2022, 2:21pm UTC](https://discuss.elastic.co/t/add-field-multiline-under-multiline-filebeat-logstash/297765 "2022-02-21T14:21:24Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![alex\_vermex](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/alex_vermex/32/101267_2.png) [@alex\_vermex](https://discuss.elastic.co/u/alex_vermex)\
**Post date:** [February 21, 2022, 2:21pm UTC](https://discuss.elastic.co/t/add-field-multiline-under-multiline-filebeat-logstash/297765/1 "2022-02-21T14:21:24Z")

</div>

Hi,  
I would like to know if I can add a field if I find a word in the message but with just a block of lines.  
log file example:

```auto
2022-01-01 17:27:56 - Starting d........
2022-12-22 17:27:59 - Run.....
.
.
2022-01-01 17:28:12 - request in format is =>
000000: 04 77 02 76 40 11 33 3...... | MS7.12121212
.
.
002040: 20 20 20 14 14 14 ....... | 0035SOAA   
2022-01-01 17:28:52 - testing timeout
2022-01-01 17:28:54 - timeout in format is =>
000116: 02 53 13 46 45 ...... | S?9.212121
.
.
002040: 20 20 20 14 14 14 ....... | 0035SOAA
2022-01-01 17:29:32 - end

```

filebeat.yml

```auto
multiline.type: pattern
multiline.pattern: '^\d{4}-\d{2}-\d{2}\s\d{2}:\d{2}:\d{2}\s{3}-\sStarting'
multiline.negate: true
multiline.match: after
multiline.max_lines: 140

```

I want to add a field when i found "format" in message with multiline value when i found date  
I hope you understand me.

Any help would be sincerely appreciate!  
Thanks!

---

<div class="post-metadata">

**Author:** ![alex\_vermex](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/alex_vermex/32/101267_2.png) [@alex\_vermex](https://discuss.elastic.co/u/alex_vermex)\
**Post date:** [February 22, 2022, 1:53pm UTC](https://discuss.elastic.co/t/add-field-multiline-under-multiline-filebeat-logstash/297765/2 "2022-02-22T13:53:15Z")

</div>

I tried to solve it with the grok filter:

```auto
if ("format" in [message]) {
        grok { match => { "message" => "(?<format>^\d{6}:[^(\r\n)]*(\n)^\d{6}:[^(\r\n)]*(\n))" }}
    }

```

but it gives me the first line so i want this whole block of lines sometimes i have 20 lines so it's a bad idea to keep writing with regular expressions and sometimes just 5 lines...  
a solution please?

Thanks.

---

<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:** [March 22, 2022, 1:54pm UTC](https://discuss.elastic.co/t/add-field-multiline-under-multiline-filebeat-logstash/297765/3 "2022-03-22T13:54:08Z")

</div>

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