# Add field problem logstash

**URL:** <https://discuss.elastic.co/t/add-field-problem-logstash/297858>\
**Category:** Logstash\
**Created:** [February 22, 2022, 8:18am UTC](https://discuss.elastic.co/t/add-field-problem-logstash/297858 "2022-02-22T08:18:01Z")\
**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 22, 2022, 8:18am UTC](https://discuss.elastic.co/t/add-field-problem-logstash/297858/1 "2022-02-22T08:18:01Z")

</div>

Hi,  
I would like to know if I can add field if I find a word in the message but under a block of lines.  
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

```

So my message now contains multilines sometimes so can i add fied if i found "id alex" for example?

```auto
2022-01-01 17:17:13 - id alex =>00011223344556677

```

I want to add fied id alex with value "00011223344556677"  
i dont know if there is any solution to this if not there is another methode to do this ?

---

<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, 10:18am UTC](https://discuss.elastic.co/t/add-field-problem-logstash/297858/3 "2022-02-22T10:18:52Z")

</div>

ok i did it with grok but i when i have another value in another line in the same message i mean like this:

```auto
2022-01-01 17:17:13 - id alex =>00011223344556677
2022-01-01 17:18:15 - number =>00335566221144

```

i did this but didnt work, when i tried in dev tools Grok debugger it works:

```auto
filter {
    if ("id alex" in [message] and "number" in [message]) {
        grok { match => { "message" => "(?<id>^\d{4}-\d{2}-\d{2}\s\d{2}:\d{2}:\d{2}\s{3}-\sid\salex\sis\s\S{2}*)(\r\n|\r|\n)(?<number>^\d{4}-\d{2}-\d{2}\s\d{2}:\d{2}:\d{2}\s{3}-\snumber\sis\s\S{2}*)
" } }
    }

```

I would like to know what is the problem. because I don't get any error.

Any help would be sincerely appreciate!  
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, 10:18am UTC](https://discuss.elastic.co/t/add-field-problem-logstash/297858/4 "2022-03-22T10:18:53Z")

</div>

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