# How to dynamically move nested key value to root level

**URL:** <https://discuss.elastic.co/t/how-to-dynamically-move-nested-key-value-to-root-level/180006>\
**Category:** Logstash\
**Created:** [May 7, 2019, 2:30pm UTC](https://discuss.elastic.co/t/how-to-dynamically-move-nested-key-value-to-root-level/180006 "2019-05-07T14:30:54Z")\
**Posts on this page:** 1\
**Showing post:** 2

<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:** [May 7, 2019, 3:14pm UTC](https://discuss.elastic.co/t/how-to-dynamically-move-nested-key-value-to-root-level/180006/2 "2019-05-07T15:14:28Z")

</div>

```
    ruby {
        code => '
            event.get("doc").each { |k, v|
                event.set(k,v)
            }
            event.remove("doc")
        '
    }
```

---

_[View the full topic](https://discuss.elastic.co/t/how-to-dynamically-move-nested-key-value-to-root-level/180006)._
