# Delete old data from Static index

**URL:** <https://discuss.elastic.co/t/delete-old-data-from-static-index/72671>\
**Category:** Elasticsearch\
**Created:** [January 24, 2017, 4:39pm UTC](https://discuss.elastic.co/t/delete-old-data-from-static-index/72671 "2017-01-24T16:39:19Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![kishorramanan](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kishorramanan/32/12823_2.png) [@kishorramanan](https://discuss.elastic.co/u/kishorramanan)\
**Post date:** [January 24, 2017, 4:39pm UTC](https://discuss.elastic.co/t/delete-old-data-from-static-index/72671/1 "2017-01-24T16:39:19Z")

</div>

**Tools:**  
Elasticsearch: 2.4  
Curator: 4.2.3.post1

**Index:**

> green open weblogic 5 1 553689832 0 284.5gb 142.1gb  
> green open apache 5 1 293808899 0 140.4gb 70.2gb

I would like to _ **retain only last 2 weeks documents** _ from the above two index.  
How do I do it?  
I tried curator - initially to show the matching index then to delete

**Curator Command:**

> curator\_cli   
> --host [internal-elk-mgmt-int-218236766.us-east-1.elb.amazonaws.com](http://internal-elk-mgmt-int-218236766.us-east-1.elb.amazonaws.com)   
> show\_indices --filter\_list '[{"filtertype":"age","source":"name","direction":"older","timestring":"'%Y.%m.%d'","unit":"days","unit\_count":14},{"filtertype":"pattern","kind":"prefix","value":"apache"}]'

I am not exactly sure on how to use this curator - kinda confusing to me  
Or if there is any other tools kindly suggest me

---

<div class="post-metadata">

**Author:** ![theuntergeek](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/theuntergeek/32/44961_2.png) [@theuntergeek](https://discuss.elastic.co/u/theuntergeek)\
**Post date:** [January 24, 2017, 6:00pm UTC](https://discuss.elastic.co/t/delete-old-data-from-static-index/72671/2 "2017-01-24T18:00:42Z")

</div>

Curator is for managing entire indices. It will not delete data from within an index. You need the delete\_by\_query plugin if you're going to do that.

I recommend, however, using time-series indices for the future so you can just drop indices with Curator, as running a delete\_by\_query to delete gigabytes of data is a painfully slow operation, by comparison.

---

<div class="post-metadata">

**Author:** ![kishorramanan](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kishorramanan/32/12823_2.png) [@kishorramanan](https://discuss.elastic.co/u/kishorramanan)\
**Post date:** [February 1, 2017, 6:27am UTC](https://discuss.elastic.co/t/delete-old-data-from-static-index/72671/3 "2017-02-01T06:27:07Z")

</div>

Thanks Aaron  
After some struggle was able ti use delete\_by\_query, is there any specific output on the delete action? I am able to see only he delete time status via the HQ plugin  
 ![](https://us1.discourse-cdn.com/elastic/original/2X/2/2a19097c3e3158779594bfa6b98ee955b6f2e9c0.png)

Also, for time-series indices - could you share some insights?  
Is there any script available to do it?

---

<div class="post-metadata">

**Author:** ![theuntergeek](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/theuntergeek/32/44961_2.png) [@theuntergeek](https://discuss.elastic.co/u/theuntergeek)\
**Post date:** [February 1, 2017, 5:12pm UTC](https://discuss.elastic.co/t/delete-old-data-from-static-index/72671/4 "2017-02-01T17:12:45Z")

</div>

> [@kishorramanan](#):
>
> Also, for time-series indices - could you share some insights? Is there any script available to do it?

How is your data getting into Elasticsearch now? There are a few ways you can do it. One is with the rollover API, which has a 1:1 alias mapped so your data would always be sent to the same index/alias name, and old data is rolled out. Logstash and Beats automatically send data into named time-series indices based on a timestamp field.

---

<div class="post-metadata">

**Author:** ![kishorramanan](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kishorramanan/32/12823_2.png) [@kishorramanan](https://discuss.elastic.co/u/kishorramanan)\
**Post date:** [February 1, 2017, 5:34pm UTC](https://discuss.elastic.co/t/delete-old-data-from-static-index/72671/6 "2017-02-01T17:34:54Z")

</div>

I have 4 major index: weblogic, apache, lambda & ec2  
The logstash servers feed to elastic-search

Not sure - Correct me if I am wrong, what I thought was I could create index based on date weblogicfeb012017 and alias it to weblogic  
Next day create weblogicfeb022017 alias it to weblogic and close the old one

Will rollover satisfy this?

---

<div class="post-metadata">

**Author:** ![theuntergeek](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/theuntergeek/32/44961_2.png) [@theuntergeek](https://discuss.elastic.co/u/theuntergeek)\
**Post date:** [February 1, 2017, 6:22pm UTC](https://discuss.elastic.co/t/delete-old-data-from-static-index/72671/7 "2017-02-01T18:22:54Z")

</div>

> [@kishorramanan](#):
>
> Will rollover satisfy this?

It should, yes.

---

<div class="post-metadata">

**Author:** ![kishorramanan](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kishorramanan/32/12823_2.png) [@kishorramanan](https://discuss.elastic.co/u/kishorramanan)\
**Post date:** [February 1, 2017, 6:48pm UTC](https://discuss.elastic.co/t/delete-old-data-from-static-index/72671/8 "2017-02-01T18:48:23Z")

</div>

> [@theuntergeek](#):
>
> It should, yes

Great! Will try that

If not rollover do i have any other options?

---

<div class="post-metadata">

**Author:** ![theuntergeek](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/theuntergeek/32/44961_2.png) [@theuntergeek](https://discuss.elastic.co/u/theuntergeek)\
**Post date:** [February 1, 2017, 7:28pm UTC](https://discuss.elastic.co/t/delete-old-data-from-static-index/72671/9 "2017-02-01T19:28:41Z")

</div>

That depends largely on how you're sending that data right now.

---

<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, 2017, 7:28pm UTC](https://discuss.elastic.co/t/delete-old-data-from-static-index/72671/10 "2017-03-01T19:28:49Z")

</div>

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