# Reference a value from new added field within grok match setting

**URL:** <https://discuss.elastic.co/t/reference-a-value-from-new-added-field-within-grok-match-setting/299619>\
**Category:** Logstash\
**Created:** [March 14, 2022, 12:33pm UTC](https://discuss.elastic.co/t/reference-a-value-from-new-added-field-within-grok-match-setting/299619 "2022-03-14T12:33:59Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![mstojanovic](https://avatars.discourse-cdn.com/v4/letter/m/dc4da7/32.png) [@mstojanovic](https://discuss.elastic.co/u/mstojanovic)\
**Post date:** [March 14, 2022, 12:33pm UTC](https://discuss.elastic.co/t/reference-a-value-from-new-added-field-within-grok-match-setting/299619/1 "2022-03-14T12:33:59Z")

</div>

Hi,

I'm trying to reference a value from a new field that was added with mutate plugin. I try to reference it within a grok match settings.

Part of the filter pipeline looks like:

```auto
filter {
      mutate {
         add_field => {
           "field_1" => "aws"
           "field_2" => "test"
           "field_3" => "%{container_name}"
         }
     }
    if [field_1] and [field_2] and [field_3] != "" {
      grok {
         match => ["log", "(\w{3}\s\d{2}\s\d{2}:\d{2}:\d{2})\s([^\s]+)\s(somestring\.)[field_1].*"]
      }
   }
}
output { stdout {} }

```

I have tried to reference a field with following options:

```auto
match => ["log", "(\w{3}\s\d{2}\s\d{2}:\d{2}:\d{2})\s([^\s]+)\s(somestring\.)[field_1].*"]
match => ["log", "(\w{3}\s\d{2}\s\d{2}:\d{2}:\d{2})\s([^\s]+)\s(somestring\.)[[field_1]].*"]
match => ["log", "(\w{3}\s\d{2}\s\d{2}:\d{2}:\d{2})\s([^\s]+)\s(somestring\.)%{field_1}.*"]
match => ["log", "(\w{3}\s\d{2}\s\d{2}:\d{2}:\d{2})\s([^\s]+)\s(somestring\.)%{[field_1]}.*"]
match => ["log", "(\w{3}\s\d{2}\s\d{2}:\d{2}:\d{2})\s([^\s]+)\s(somestring\.)[field_1].*"]
match => ["log", "(\w{3}\s\d{2}\s\d{2}:\d{2}:\d{2})\s([^\s]+)\s(somestring\.)([field_1].*)"]

```

Can anyone help and suggest how else I can try to reference a new added field value through match setting in grok filter plugin?

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:** [April 11, 2022, 12:34pm UTC](https://discuss.elastic.co/t/reference-a-value-from-new-added-field-within-grok-match-setting/299619/2 "2022-04-11T12:34:32Z")

</div>

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