# A new index for each container?

**URL:** <https://discuss.elastic.co/t/a-new-index-for-each-container/253394>\
**Category:** Logstash\
**Tags:** docker\
**Created:** [October 27, 2020, 6:54am UTC](https://discuss.elastic.co/t/a-new-index-for-each-container/253394 "2020-10-27T06:54:37Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![nyquillus](https://avatars.discourse-cdn.com/v4/letter/n/c77e96/32.png) [@nyquillus](https://discuss.elastic.co/u/nyquillus)\
**Post date:** [October 27, 2020, 6:54am UTC](https://discuss.elastic.co/t/a-new-index-for-each-container/253394/1 "2020-10-27T06:54:37Z")

</div>

Hi,

I am currently running a test environment to try gelf logging driver to monitor container logs with a single node stack and so far it worked well. But I need to make some changes and I'm pretty new to this so I need some help. Each container's logs are being sent to a single index which is "logstash\*", I want seperate indexes for each container preferebly using gelf logging driver. If this has a solution through another driver I'm open to hear that as well.

Thanks in advance.

---

<div class="post-metadata">

**Author:** ![nyquillus](https://avatars.discourse-cdn.com/v4/letter/n/c77e96/32.png) [@nyquillus](https://discuss.elastic.co/u/nyquillus)\
**Post date:** [October 27, 2020, 9:28am UTC](https://discuss.elastic.co/t/a-new-index-for-each-container/253394/2 "2020-10-27T09:28:58Z")

</div>

I found the solution for this if anyone else gets stuck at this,

add a tag option when creating your container with the other logging driver options you have.  
then change your logstash.conf output:

```
output {
    elasticsearch {
        hosts => ["elasticsearch:9200"]
        index => "%{tag}-%{+YYYY-MM-dd}"
    }
}
```

---

<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:** [November 24, 2020, 9:29am UTC](https://discuss.elastic.co/t/a-new-index-for-each-container/253394/3 "2020-11-24T09:29:09Z")

</div>

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