# Logstash output: dynamically multiple indexes

**URL:** <https://discuss.elastic.co/t/logstash-output-dynamically-multiple-indexes/72008>\
**Category:** Logstash\
**Created:** [January 18, 2017, 1:38pm UTC](https://discuss.elastic.co/t/logstash-output-dynamically-multiple-indexes/72008 "2017-01-18T13:38:50Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![asp](https://avatars.discourse-cdn.com/v4/letter/a/9fc348/32.png) [@asp](https://discuss.elastic.co/u/asp)\
**Post date:** [January 18, 2017, 1:38pm UTC](https://discuss.elastic.co/t/logstash-output-dynamically-multiple-indexes/72008/1 "2017-01-18T13:38:50Z")

</div>

Hi,

we have logs of our production, qa and dev systems in the same elasticsearch database.  
Currently we have one index for all, and I want to separate it, with the target:

- higher performance
- lower storage usage
- different retention time for production and non production.

To not to have to many indizes and shards, I would like to have indizes as followed:  
metricbeat-prod-YYYY.MM.DD  
metricbeat-staging-YYY.MM.DD  
logcluster1-prod-YYYY.MM.DD  
logcluster1-staging-YYYY.MM.DD  
...

I noticed, that I can use field names in output using %{fieldname} within the index value field.  
So I could create the index prefix (prod / staging) a filter or send it by filebeat.

but the point is, can I set a local variable in the output filter, which is not stored as field?  
because I don't need the information as field in elasticsearch, only for routing.

Thanks, Andreas

---

<div class="post-metadata">

**Author:** ![magnusbaeck](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/magnusbaeck/32/44943_2.png) [@magnusbaeck](https://discuss.elastic.co/u/magnusbaeck)\
**Post date:** [January 18, 2017, 1:52pm UTC](https://discuss.elastic.co/t/logstash-output-dynamically-multiple-indexes/72008/2 "2017-01-18T13:52:55Z")

</div>

> but the point is, can I set a local variable in the output filter, which is not stored as field?

Yes, store the field as a subfield to `@metadata`.

> **[Accessing event data and fields | Logstash Reference \[8.11\] | Elastic](https://www.elastic.co/guide/en/logstash/current/event-dependent-configuration.html#metadata)**

---

<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:** [February 15, 2017, 1:52pm UTC](https://discuss.elastic.co/t/logstash-output-dynamically-multiple-indexes/72008/3 "2017-02-15T13:52:56Z")

</div>

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