# Mutate only works at the top level?

**URL:** <https://discuss.elastic.co/t/mutate-only-works-at-the-top-level/52893>\
**Category:** Logstash\
**Created:** [June 15, 2016, 4:27pm UTC](https://discuss.elastic.co/t/mutate-only-works-at-the-top-level/52893 "2016-06-15T16:27:40Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![iamthealex](https://avatars.discourse-cdn.com/v4/letter/i/e9c0ed/32.png) [@iamthealex](https://discuss.elastic.co/u/iamthealex)\
**Post date:** [June 15, 2016, 4:27pm UTC](https://discuss.elastic.co/t/mutate-only-works-at-the-top-level/52893/1 "2016-06-15T16:27:40Z")

</div>

Here is rename.conf  
input {  
stdin {}  
}

filter {  
mutate { add\_field =\> { "[b]" =\> "bozo" } }  
mutate { rename =\> ["[b]", "[fancy][pants]" ] }  
}

output {  
stdout { codec =\> rubydebug { metadata =\> true } }  
}

Here is rename2.conf  
input {  
stdin {}  
}

filter {  
mutate { add\_field =\> { "[@metadata][b]" =\> "bozo" } }  
mutate { rename =\> ["[@metadata][b]", "[fancy][pants]" ] }  
}

output {  
stdout { codec =\> rubydebug { metadata =\> true } }  
}

The only difference is using [@metadata]  
However, the first one works as I expected and the second one does not.

[anelson@localhost logstash-2.3.2]$ bin/logstash -f ~/elk/configs/rename.conf  
Settings: Default pipeline workers: 4  
Pipeline main started  
fubar  
{  
"message" =\> "fubar",  
"@version" =\> "1",  
"@timestamp" =\> "2016-06-15T16:22:26.052Z",  
"host" =\> "localhost.localdomain",  
"fancy" =\> {  
"pants" =\> "bozo"  
}  
}  
Pipeline main has been shutdown  
stopping pipeline {:id=\>"main"}  
[anelson@localhost logstash-2.3.2]$ bin/logstash -f ~/elk/configs/rename2.conf  
Settings: Default pipeline workers: 4  
fubar  
{  
"message" =\> "fubar",  
"@version" =\> "1",  
"@timestamp" =\> "2016-06-15T16:22:40.207Z",  
"host" =\> "localhost.localdomain",  
"fancy" =\> {  
**"pants" =\> nil**  
},  
"@metadata" =\> {  
"b" =\> "bozo"  
}  
}

---

<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 6, 2017, 4:52am UTC](https://discuss.elastic.co/t/mutate-only-works-at-the-top-level/52893/2 "2017-07-06T04:52:40Z")

</div>

Closed on July 6, 2017, 4:52am UTC


