# Mutate -\> Copy is not working as expected

**URL:** https://discuss.elastic.co/t/mutate-copy-is-not-working-as-expected/333541
**Category:** Logstash
**Created:** [May 16, 2023, 8:53am UTC](https://discuss.elastic.co/t/mutate-copy-is-not-working-as-expected/333541 "2023-05-16T08:53:43Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![FALEN](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/falen/32/82754_2.png) [@FALEN](https://discuss.elastic.co/u/FALEN)
#### Post date: [May 16, 2023, 8:53am UTC](https://discuss.elastic.co/t/mutate-copy-is-not-working-as-expected/333541/1 "2023-05-16T08:53:43Z")

</div>

Im working on some json data, transforming and remapping fields  
add\_field, rename plugins are working as expected

But whenever im using copy, output does not include these [events][date], [env][app] fields. But does include [env][date]. That means field is not empty and format is proper i assume?  
Also tried with an alternative, using add\_field to produce target fields as empty to see if copy failing to create field in first place or not.

```auto
filter {
if [log][file][path] =~ "/var/log/trace/*" {
    mutate {
        copy => {
        "[type1][timestamp]" => "[events][date]"
        "[type1][tags][http.path]" => "[env][app]"
        }
        rename => {
        "[type1][timestamp]" => "[env][date]"
        }
        remove_field => ["^type1\."]
    }
  }
}

```

Updated to latest 8.x.x to test, same happens again

---

<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 16, 2023, 2:42pm UTC](https://discuss.elastic.co/t/mutate-copy-is-not-working-as-expected/333541/3 "2023-05-16T14:42:54Z")

</div>

A mutate filter processes options in a [fixed order](https://www.elastic.co/guide/en/logstash/current/plugins-filters-mutate.html#plugins-filters-mutate-proc_order). rename is processed before copy. [type1][timestamp] will no longer exist when the filter tries to copy it, so it does not get copied. Use two mutate filters.

---

<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: [June 13, 2023, 2:43pm UTC](https://discuss.elastic.co/t/mutate-copy-is-not-working-as-expected/333541/4 "2023-06-13T14:43:42Z")

</div>

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