# Which ways to copy subfields of kubernetes.container.\_module.labels.\* to kubernetes.lables.\*?

**URL:** <https://discuss.elastic.co/t/which-ways-to-copy-subfields-of-kubernetes-container-module-labels-to-kubernetes-lables/195546>\
**Category:** Logstash\
**Created:** [August 16, 2019, 6:32pm UTC](https://discuss.elastic.co/t/which-ways-to-copy-subfields-of-kubernetes-container-module-labels-to-kubernetes-lables/195546 "2019-08-16T18:32:32Z")\
**Posts on this page:** 1\
**Showing post:** 5

<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:** [August 16, 2019, 7:46pm UTC](https://discuss.elastic.co/t/which-ways-to-copy-subfields-of-kubernetes-container-module-labels-to-kubernetes-lables/195546/5 "2019-08-16T19:46:22Z")

</div>

mutate+copy is a no-op if a field does not exist, so you can compress this down to

```
mutate {
    copy => {
        "[kubernetes][container][_module][labels]" => "[kubernetes][labels]"
        "[kubernetes][container][_module][namespace]" => "[kubernetes][namespace]"
        "[kubernetes][container][_module][node]" => "[kubernetes][node]"
        "[kubernetes][container][_module][pod]" => "[kubernetes][pod]"
        "[kubernetes][pod][_module][labels]" => "[kubernetes][labels]"
        "[kubernetes][pod][_module][namespace]" => "[kubernetes][namespace]"
        "[kubernetes][pod][_module][node]" => "[kubernetes][node]"
        "[kubernetes][node][_module][labels]" => "[kubernetes][labels]"
        "[kubernetes][volume][_module][labels]" => "[kubernetes][labels]"
        "[kubernetes][volume][_module][namespace]" => "[kubernetes][namespace]"
        "[kubernetes][volume][_module][node]" => "[kubernetes][node]"
        "[kubernetes][volume][_module][pod]" => "[kubernetes][pod]"
        "[kubernetes][system][_module][labels]" => "[kubernetes][labels]"
        "[kubernetes][system][_module][node]" => "[kubernetes][node]"
    }
 }

```

assuming that only one of the sets of node/labels/pod will be present.

---

_[View the full topic](https://discuss.elastic.co/t/which-ways-to-copy-subfields-of-kubernetes-container-module-labels-to-kubernetes-lables/195546)._
