# Logstash add\_field issue

**URL:** <https://discuss.elastic.co/t/logstash-add-field-issue/186121>\
**Category:** Logstash\
**Created:** [June 17, 2019, 5:07pm UTC](https://discuss.elastic.co/t/logstash-add-field-issue/186121 "2019-06-17T17:07:28Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Elk\_huh](https://avatars.discourse-cdn.com/v4/letter/e/d26b3c/32.png) [@Elk\_huh](https://discuss.elastic.co/u/Elk_huh)\
**Post date:** [June 17, 2019, 5:07pm UTC](https://discuss.elastic.co/t/logstash-add-field-issue/186121/1 "2019-06-17T17:07:28Z")

</div>

I am aware you can replace a field but I need to copy the content from the field agent.\_id to a new field called AgentIdentifier for testing purposes .

```
mutate {

```

add\_field =\> {"AgentIdentifier", "%{[fields][agent.\_id]}"}  
}

What am i doing wrong here ?

---

<div class="post-metadata">

**Author:** ![Badger](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/badger/32/25190_2.png) [@Badger](https://discuss.elastic.co/u/Badger)\
**Post date:** [June 17, 2019, 5:13pm UTC](https://discuss.elastic.co/t/logstash-add-field-issue/186121/2 "2019-06-17T17:13:50Z")

</div>

[fields][agent.\_id] refers to a field with a dot in its name inside the [fields] object. My guess is you want the field called \_id inside the agent object, which would be [agent][id]. Not sure whether you really want [fields] or not.

---

<div class="post-metadata">

**Author:** ![Badger](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/badger/32/25190_2.png) [@Badger](https://discuss.elastic.co/u/Badger)\
**Post date:** [June 17, 2019, 5:55pm UTC](https://discuss.elastic.co/t/logstash-add-field-issue/186121/5 "2019-06-17T17:55:38Z")

</div>

So use %{[agent][id]}

---

<div class="post-metadata">

**Author:** ![Elk\_huh](https://avatars.discourse-cdn.com/v4/letter/e/d26b3c/32.png) [@Elk\_huh](https://discuss.elastic.co/u/Elk_huh)\
**Post date:** [June 17, 2019, 6:04pm UTC](https://discuss.elastic.co/t/logstash-add-field-issue/186121/6 "2019-06-17T18:04:30Z")

</div>

> [@Elk\_huh](#):
>
> add\_field =\> {"AgentIdentifier", "%{[fields][agent.\_id]}"}

ohh, thats what you meant . i had syntax wrong

Thank you!

---

<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:** [July 15, 2019, 6:04pm UTC](https://discuss.elastic.co/t/logstash-add-field-issue/186121/7 "2019-07-15T18:04:33Z")

</div>

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