# Logstash - mutate - add\_field problem

**URL:** <https://discuss.elastic.co/t/logstash-mutate-add-field-problem/65665>\
**Category:** Logstash\
**Created:** [November 10, 2016, 1:25pm UTC](https://discuss.elastic.co/t/logstash-mutate-add-field-problem/65665 "2016-11-10T13:25:17Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Nadir](https://avatars.discourse-cdn.com/v4/letter/n/e5b9ba/32.png) [@Nadir](https://discuss.elastic.co/u/Nadir)\
**Post date:** [November 10, 2016, 1:25pm UTC](https://discuss.elastic.co/t/logstash-mutate-add-field-problem/65665/1 "2016-11-10T13:25:17Z")

</div>

Hi !

I do have the following event and I want to add another field and populate this with the content of event\_data.IpAddress:

```
{
       "process_id" => 476,
       "level" => "Information",
        "event_data" => {
                        "IpAddress" => "172.16.87.87",
                        "ProcessId" => "0x0"
        },
        "opcode" => "Info",
        "type" => "wineventlog",
        "event_id" => 4624
}

```

In the logstash config I added this to achieve this, but it doesn't work:

```
...
filter {
    mutate {
        add_field => { "host" => "%{event_data.IpAddress} }
}
...

```

It does work if I take for example the event\_id:

```
...
filter {
  mutate {
    add_field => { "host" => "%{event_id}}
  }
...

```

Any suggestion ?

Kind regards,  
Thorsten

---

<div class="post-metadata">

**Author:** ![tileaga](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/tileaga/32/13063_2.png) [@tileaga](https://discuss.elastic.co/u/tileaga)\
**Post date:** [November 10, 2016, 1:29pm UTC](https://discuss.elastic.co/t/logstash-mutate-add-field-problem/65665/2 "2016-11-10T13:29:32Z")

</div>

Try this:

`add_field => ["[host]", "%{event_data.IpAddress}" ]`

---

<div class="post-metadata">

**Author:** ![magnusbaeck](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/magnusbaeck/32/44943_2.png) [@magnusbaeck](https://discuss.elastic.co/u/magnusbaeck)\
**Post date:** [November 10, 2016, 1:47pm UTC](https://discuss.elastic.co/t/logstash-mutate-add-field-problem/65665/3 "2016-11-10T13:47:37Z")

</div>

`%{[event_data][IpAddress]}`, not `%{event_data.IpAddress}`.

[https://www.elastic.co/guide/en/logstash/current/event-dependent-configuration.html#logstash-config-field-references](https://www.elastic.co/guide/en/logstash/current/event-dependent-configuration.html#logstash-config-field-references)

---

<div class="post-metadata">

**Author:** ![Nadir](https://avatars.discourse-cdn.com/v4/letter/n/e5b9ba/32.png) [@Nadir](https://discuss.elastic.co/u/Nadir)\
**Post date:** [November 10, 2016, 1:49pm UTC](https://discuss.elastic.co/t/logstash-mutate-add-field-problem/65665/4 "2016-11-10T13:49:55Z")

</div>

This approach does create this additional field and content:

...  
"host" =\> "%{event\_data.IpAddress}",  
...

Not what I need as I need the content of the field 'event\_data.IpAddress' in the new field 'host'.

---

<div class="post-metadata">

**Author:** ![Nadir](https://avatars.discourse-cdn.com/v4/letter/n/e5b9ba/32.png) [@Nadir](https://discuss.elastic.co/u/Nadir)\
**Post date:** [November 10, 2016, 1:57pm UTC](https://discuss.elastic.co/t/logstash-mutate-add-field-problem/65665/5 "2016-11-10T13:57:06Z")

</div>

The solution from Magnus is working:

`add_field => { "host" => "%{[event_data][IpAddress]}" }`

Thank's a lot !  
Thorsten

---

<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:** [December 8, 2016, 1:57pm UTC](https://discuss.elastic.co/t/logstash-mutate-add-field-problem/65665/6 "2016-12-08T13:57:11Z")

</div>

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