# Add tag dynamically to create index dynamically

**URL:** <https://discuss.elastic.co/t/add-tag-dynamically-to-create-index-dynamically/164794>\
**Category:** Logstash\
**Created:** [January 18, 2019, 12:49pm UTC](https://discuss.elastic.co/t/add-tag-dynamically-to-create-index-dynamically/164794 "2019-01-18T12:49:41Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Roque\_Moyano](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/roque_moyano/32/116329_2.png) [@Roque\_Moyano](https://discuss.elastic.co/u/Roque_Moyano)\
**Post date:** [January 18, 2019, 12:49pm UTC](https://discuss.elastic.co/t/add-tag-dynamically-to-create-index-dynamically/164794/1 "2019-01-18T12:49:41Z")

</div>

Hi , I'm trying to create an index for every application that we have in our company , like : index-app1 , index-app2 , we have a lot of team and every team is owner about theirs apps , so I'm trying that approach so be easily make filters , visualizations and so on. I have all the apps dockerized , and every docker have its own log file with the name of the app , ej app1.log , app2.log etc. So having say that I would like to take the filename and create the index with that. that is possible? or maybe another approach ?

thanks in advance

---

<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:** [January 18, 2019, 1:20pm UTC](https://discuss.elastic.co/t/add-tag-dynamically-to-create-index-dynamically/164794/2 "2019-01-18T13:20:35Z")

</div>

If you are using a file input then every event will have a field called path that contains the path to the file. If the name of the file contains the app name then you can use a dissect or grok filter to extract the app name into another field. Then you can use a field reference to build the index name from that field.

```
index => "%{app}..."

```

That said, if this approach ends up causing you to have a large number of small indexes your performance will suffer from the overhead involved in managing a large number of shards.

---

<div class="post-metadata">

**Author:** ![Roque\_Moyano](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/roque_moyano/32/116329_2.png) [@Roque\_Moyano](https://discuss.elastic.co/u/Roque_Moyano)\
**Post date:** [January 18, 2019, 1:30pm UTC](https://discuss.elastic.co/t/add-tag-dynamically-to-create-index-dynamically/164794/3 "2019-01-18T13:30:15Z")

</div>

Thanks Badger , if the performance get overheaded maybe i'm not getting the right solutions , maybe just adding a tag with the name of the app and sharing the same index could be better , How can I extract a text from a logstash field?

---

<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:** [January 18, 2019, 1:40pm UTC](https://discuss.elastic.co/t/add-tag-dynamically-to-create-index-dynamically/164794/4 "2019-01-18T13:40:43Z")

</div>

As I said, use either a [dissect](https://www.elastic.co/guide/en/logstash/current/plugins-filters-dissect.html) or [grok](https://www.elastic.co/guide/en/logstash/current/plugins-filters-grok.html) filter.

---

<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, 2019, 1:40pm UTC](https://discuss.elastic.co/t/add-tag-dynamically-to-create-index-dynamically/164794/5 "2019-02-15T13:40:56Z")

</div>

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