# How to let Functionbeat write to multiple indices

**URL:** <https://discuss.elastic.co/t/how-to-let-functionbeat-write-to-multiple-indices/262614>\
**Category:** Beats\
**Tags:** functionbeat\
**Created:** [January 29, 2021, 8:21am UTC](https://discuss.elastic.co/t/how-to-let-functionbeat-write-to-multiple-indices/262614 "2021-01-29T08:21:21Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![yahya92](https://avatars.discourse-cdn.com/v4/letter/y/c67d28/32.png) [@yahya92](https://discuss.elastic.co/u/yahya92)\
**Post date:** [January 29, 2021, 8:21am UTC](https://discuss.elastic.co/t/how-to-let-functionbeat-write-to-multiple-indices/262614/1 "2021-01-29T08:21:22Z")

</div>

Hello  
Is there a way to let Functionbeat write to multiple indices?  
I have seen that it can write to only one of many indices according to defined rules.  
Example:  
output.elasticsearch:  
indices:  
- index: "index-first"  
when.contains:  
message: "field1"  
- index: "index-second"  
when.contains:  
message: "field2"

The above will write to index-first if field1 exists and to index-second if field2 exists.  
What I want is to write tow copies of same data to both indices, can that be done from Functionbeat side?

---

<div class="post-metadata">

**Author:** ![kvch](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kvch/32/72058_2.png) [@kvch](https://discuss.elastic.co/u/kvch)\
**Post date:** [February 1, 2021, 12:37pm UTC](https://discuss.elastic.co/t/how-to-let-functionbeat-write-to-multiple-indices/262614/2 "2021-02-01T12:37:02Z")

</div>

As all Beats, Functionbeat can write to multiple indices as well as seen in the docs: [Configure the Elasticsearch output | Functionbeat Reference [7.10] | Elastic](https://www.elastic.co/guide/en/beats/functionbeat/current/elasticsearch-output.html#indices-option-es)

However, after you change the configuration of the Beat, you have to redeploy the function. Thus, the new options can be picked by the Beat.

Also, if you have problems with a specific configuration, please share it and format it using `</>`.

---

<div class="post-metadata">

**Author:** ![yahya92](https://avatars.discourse-cdn.com/v4/letter/y/c67d28/32.png) [@yahya92](https://discuss.elastic.co/u/yahya92)\
**Post date:** [February 1, 2021, 1:11pm UTC](https://discuss.elastic.co/t/how-to-let-functionbeat-write-to-multiple-indices/262614/3 "2021-02-01T13:11:43Z")

</div>

Hello Kvch, thank you for your reply  
As per docs and the things I tried.  
"Functionbeat uses the first matching rule in the array."  
so Functionbeat will write to only the first index that matches the rule.  
What I want is that Functionbeat write to two indices, not just the first one that matches the rule.  
Hope my need is clear now.  
Thanks

---

<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:** [March 1, 2021, 3:11pm UTC](https://discuss.elastic.co/t/how-to-let-functionbeat-write-to-multiple-indices/262614/4 "2021-03-01T15:11:56Z")

</div>

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