# Create nested field

**URL:** <https://discuss.elastic.co/t/create-nested-field/47222>\
**Category:** Logstash\
**Created:** [April 13, 2016, 9:19am UTC](https://discuss.elastic.co/t/create-nested-field/47222 "2016-04-13T09:19:07Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![boernd](https://avatars.discourse-cdn.com/v4/letter/b/3e96dc/32.png) [@boernd](https://discuss.elastic.co/u/boernd)\
**Post date:** [April 13, 2016, 9:19am UTC](https://discuss.elastic.co/t/create-nested-field/47222/1 "2016-04-13T09:19:07Z")

</div>

Hi,

is there a better way to create a nested field than my two step approach? Did not get it to work otherwise.

> mutate {  
> add\_field =\> {  
> "riemann" =\> { }  
> "riemannstate" =\> "critical"  
> "riemannservice" =\> "testservice"  
> "riemannmetric" =\> "1.0"  
> }  
> }  
> mutate {  
> rename =\> {  
> "riemannstate" =\> "[riemann][state]"  
> "riemannservice" =\> "[riemann][service]"  
> "riemannmetric" =\> "[riemann][metric]"  
> }  
> }

---

<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:** [April 13, 2016, 9:41am UTC](https://discuss.elastic.co/t/create-nested-field/47222/2 "2016-04-13T09:41:34Z")

</div>

So

```auto
mutate { 
  add_field => {
    "[riemann][state]" => "critical"
    "[riemann][service]" => "testservice"
    "[riemann][metric]" => "1.0"
  }
}

```

doesn't work?

---

<div class="post-metadata">

**Author:** ![boernd](https://avatars.discourse-cdn.com/v4/letter/b/3e96dc/32.png) [@boernd](https://discuss.elastic.co/u/boernd)\
**Post date:** [April 13, 2016, 10:05am UTC](https://discuss.elastic.co/t/create-nested-field/47222/3 "2016-04-13T10:05:51Z")

</div>

No, unfortunately not. With this approach I get the following result (ls 2.2.2)

{  
"message" =\> "",  
"@timestamp" =\> "2016-04-13T10:04:53.838Z",  
"host" =\> "virtmachine",  
"service" =\> "service",  
"metric" =\> "1.0",  
"state" =\> "critical"  
}

---

<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, 5:02am UTC](https://discuss.elastic.co/t/create-nested-field/47222/4 "2017-07-06T05:02:30Z")

</div>


