# How to use copy-to in filebeat?

**URL:** <https://discuss.elastic.co/t/how-to-use-copy-to-in-filebeat/268499>\
**Category:** Beats\
**Tags:** filebeat\
**Created:** [March 26, 2021, 1:33pm UTC](https://discuss.elastic.co/t/how-to-use-copy-to-in-filebeat/268499 "2021-03-26T13:33:57Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Chris6](https://avatars.discourse-cdn.com/v4/letter/c/b2d939/32.png) [@Chris6](https://discuss.elastic.co/u/Chris6)\
**Post date:** [March 26, 2021, 1:33pm UTC](https://discuss.elastic.co/t/how-to-use-copy-to-in-filebeat/268499/1 "2021-03-26T13:33:57Z")

</div>

I am trying to use copy\_to to copy the values of multiple fields into a group field so that it can then be queried as a single field. I found this link [copy\_to | Elasticsearch Reference [7.12] | Elastic](https://www.elastic.co/guide/en/elasticsearch/reference/current/copy-to.html) , but when I try to do it in the dev tools it doesn't work with my filebeat index. I tried it with it already index and without it being indexed. Then I tried loading in the json template into the filebeat.yml and that also did not work.

I also found this link [Copy fields | Filebeat Reference [7.12] | Elastic](https://www.elastic.co/guide/en/beats/filebeat/current/copy-fields.html), but this doesn't do the groups. Any ideas on how I could accomplish this could be great.

---

<div class="post-metadata">

**Author:** ![ChrsMark](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/chrsmark/32/55858_2.png) [@ChrsMark](https://discuss.elastic.co/u/ChrsMark)\
**Post date:** [March 26, 2021, 2:57pm UTC](https://discuss.elastic.co/t/how-to-use-copy-to-in-filebeat/268499/2 "2021-03-26T14:57:39Z")

</div>

Hi!

I think that `copy_to` needs to be specified in the mappings. In this case you will need to update the mapping for the Filebeat's fields. Where did you try to set it up?

`copy_fields` of Filebeat should work. What configuration did you tried? Maybe sth the following could do the trick:

```auto
processors:
  - copy_fields:
      fields:
        - from: message1
          to: event.message1
        - from: message2
          to: event.message2
      fail_on_error: false
      ignore_missing: true

```

---

<div class="post-metadata">

**Author:** ![Chris6](https://avatars.discourse-cdn.com/v4/letter/c/b2d939/32.png) [@Chris6](https://discuss.elastic.co/u/Chris6)\
**Post date:** [March 29, 2021, 2:42pm UTC](https://discuss.elastic.co/t/how-to-use-copy-to-in-filebeat/268499/3 "2021-03-29T14:42:21Z")

</div>

Hello

I tried to set up the mapping for copy\_to in a custom-template.json file that I made. And then in filebeat.yml I loaded in the template like

```
template:
  path: "custom-template.json"

```

This did not create the field.

For the copy\_field in filebeat I can get it to work with each thing being labeled as event.message1 and event.message2, but I am try to make it a list and not have message1 and message2 next to it, so I want it like [10, 12]. This is because I am trying to use graph in kibana and sometimes the list will be like [12, 10] and I want that to be able to be the same map as [10,12] and not create a new one.

---

<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:** [April 26, 2021, 4:43pm UTC](https://discuss.elastic.co/t/how-to-use-copy-to-in-filebeat/268499/4 "2021-04-26T16:43:11Z")

</div>

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