# Add new field with value from grok filter

**URL:** <https://discuss.elastic.co/t/add-new-field-with-value-from-grok-filter/269253>\
**Category:** Logstash\
**Created:** [April 5, 2021, 5:45pm UTC](https://discuss.elastic.co/t/add-new-field-with-value-from-grok-filter/269253 "2021-04-05T17:45:35Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Automation\_Scripts](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/automation_scripts/32/85374_2.png) [@Automation\_Scripts](https://discuss.elastic.co/u/Automation_Scripts)\
**Post date:** [April 5, 2021, 5:45pm UTC](https://discuss.elastic.co/t/add-new-field-with-value-from-grok-filter/269253/1 "2021-04-05T17:45:35Z")

</div>

Hi all,

I need to add a value to a field from a variable within a grok filter.

```auto
filter {
    grok { 
      match => ["message", "(?<ts>(.*?))\t(?<uids>(.*?))"]    
 }
    mutate { add_field => { "container_id" => "%{uids}" } }
}

```

The field is created but the value is not taken into consideration it simply puts the string %{uids}.  
How should I add the value from this grok variable to a field?

Thank you!

---

<div class="post-metadata">

**Author:** ![elasticforme](https://avatars.discourse-cdn.com/v4/letter/e/f05b48/32.png) [@elasticforme](https://discuss.elastic.co/u/elasticforme)\
**Post date:** [April 5, 2021, 7:39pm UTC](https://discuss.elastic.co/t/add-new-field-with-value-from-grok-filter/269253/2 "2021-04-05T19:39:10Z")

</div>

this is because you have %{uid} not set from grok pattern.

otherwise code looks correct

---

<div class="post-metadata">

**Author:** ![Automation\_Scripts](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/automation_scripts/32/85374_2.png) [@Automation\_Scripts](https://discuss.elastic.co/u/Automation_Scripts)\
**Post date:** [April 5, 2021, 7:51pm UTC](https://discuss.elastic.co/t/add-new-field-with-value-from-grok-filter/269253/3 "2021-04-05T19:51:13Z")

</div>

something was caching badly. worked like a charm after restart.

---

<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:** [May 3, 2021, 7:51pm UTC](https://discuss.elastic.co/t/add-new-field-with-value-from-grok-filter/269253/4 "2021-05-03T19:51:53Z")

</div>

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