# How to open indices for last 30 days only

**URL:** https://discuss.elastic.co/t/how-to-open-indices-for-last-30-days-only/128958
**Category:** Elasticsearch
**Created:** [April 21, 2018, 8:13am UTC](https://discuss.elastic.co/t/how-to-open-indices-for-last-30-days-only/128958 "2018-04-21T08:13:26Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![niraj\_kumar](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/niraj_kumar/32/4130_2.png) [@niraj\_kumar](https://discuss.elastic.co/u/niraj_kumar)
#### Post date: [April 21, 2018, 8:13am UTC](https://discuss.elastic.co/t/how-to-open-indices-for-last-30-days-only/128958/1 "2018-04-21T08:13:26Z")

</div>

Hi,

Using curator or any other way , how can i open indices for last 30 days only.

--  
Niraj

---

<div class="post-metadata">

### Author: ![FatalGlitch](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/fatalglitch/32/30106_2.png) [@FatalGlitch](https://discuss.elastic.co/u/FatalGlitch)
#### Post date: [April 21, 2018, 9:35am UTC](https://discuss.elastic.co/t/how-to-open-indices-for-last-30-days-only/128958/2 "2018-04-21T09:35:39Z")

</div>

Below is an example curator action file that looks at the index name, and uses that to determine age. Note the format below is YYYY-MM-DD (2018-04-21)

If you don't have timestamps in the index name, you can change the source to created\_date, and drop the timestring option.

Make sure you run curator with --dry-run to verify it's going to do what you want.

```
actions:
    1:
        action: open
        description: >-
            Opens the last 30 days of indices based on YYYY-MM-DD timestamp in index name
        options:
            continue_if_exception: false
        filters:
        - filtertype: age
          source: name
          timestring: '%Y-%m-%d'
          direction: younger
          unit: days
          unit_count: 30
```

---

<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: [May 19, 2018, 9:35am UTC](https://discuss.elastic.co/t/how-to-open-indices-for-last-30-days-only/128958/3 "2018-05-19T09:35:49Z")

</div>

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