# Logstash index automatically delete when new is created

**URL:** <https://discuss.elastic.co/t/logstash-index-automatically-delete-when-new-is-created/153583>\
**Category:** Logstash\
**Created:** [October 23, 2018, 10:52am UTC](https://discuss.elastic.co/t/logstash-index-automatically-delete-when-new-is-created/153583 "2018-10-23T10:52:02Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![dinesh2](https://avatars.discourse-cdn.com/v4/letter/d/eb9ed0/32.png) [@dinesh2](https://discuss.elastic.co/u/dinesh2)\
**Post date:** [October 23, 2018, 10:52am UTC](https://discuss.elastic.co/t/logstash-index-automatically-delete-when-new-is-created/153583/1 "2018-10-23T10:52:02Z")

</div>

I want to create a script that previous day index got deleted when new index created in logstash config file.

Index1: 2018-01-01  
Index2: 2018-01-02  
.  
.  
.  
IndexN:

Regards,  
Dinesh D

---

<div class="post-metadata">

**Author:** ![balumurari1](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/balumurari1/32/39203_2.png) [@balumurari1](https://discuss.elastic.co/u/balumurari1)\
**Post date:** [October 25, 2018, 8:05am UTC](https://discuss.elastic.co/t/logstash-index-automatically-delete-when-new-is-created/153583/2 "2018-10-25T08:05:23Z")

</div>

Instead of deleting index daily, create an index with unique id, so that you can update your data daily from the same index. Deleting index is not a good approach.

Why not just use a custom `_id` for each document, so that the next time it gets sent to Elasticsearch it just overwrites the existing one?

---

<div class="post-metadata">

**Author:** ![dinesh2](https://avatars.discourse-cdn.com/v4/letter/d/eb9ed0/32.png) [@dinesh2](https://discuss.elastic.co/u/dinesh2)\
**Post date:** [October 25, 2018, 9:00am UTC](https://discuss.elastic.co/t/logstash-index-automatically-delete-when-new-is-created/153583/3 "2018-10-25T09:00:18Z")

</div>

Hi Balumurari,

Actually the index created based on the current date and my question is to keep only 7 days indices and past indices to be deleted.  
And for this week indices should be deleted automatically when new week index is created.

Please suggest.

Regards,  
Dinesh D

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [October 25, 2018, 9:00am UTC](https://discuss.elastic.co/t/logstash-index-automatically-delete-when-new-is-created/153583/4 "2018-10-25T09:00:50Z")

</div>

For now, use [Elasticsearch Curator](https://www.elastic.co/guide/en/elasticsearch/client/curator/current/index.html).

---

<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 22, 2018, 9:00am UTC](https://discuss.elastic.co/t/logstash-index-automatically-delete-when-new-is-created/153583/5 "2018-11-22T09:00:51Z")

</div>

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