# Monthly rolling period with Curator

**URL:** <https://discuss.elastic.co/t/monthly-rolling-period-with-curator/135140>\
**Category:** Elasticsearch\
**Created:** [June 8, 2018, 11:27am UTC](https://discuss.elastic.co/t/monthly-rolling-period-with-curator/135140 "2018-06-08T11:27:26Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mogztter](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mogztter/32/7820_2.png) [@Mogztter](https://discuss.elastic.co/u/Mogztter)\
**Post date:** [June 8, 2018, 11:27am UTC](https://discuss.elastic.co/t/monthly-rolling-period-with-curator/135140/1 "2018-06-08T11:27:26Z")

</div>

Hello,

Is it possible to define a monthly rolling period policy with Curator ?  
I'm using daily indices with the following pattern `metrics_%{YYYY.MM.dd}`. Today index is `metrics_2018.08.06`.

What I want is to keep 1 month of metrics (no matter how many days there's in the previous month).

As far as I know, Curator is truncating the date to the most recent whole unit.  
Consider the following `actions.yml`:

```auto
  0:
    action: delete_indices
    description : DELETE INDICES metrics daily
    options:
      ignore_empty_list: True
    filters:
      - kind: regex
        filtertype: pattern
        value: ^metrics_\d{4}\.\d{2}\.\d{2}$
      - filtertype: period
        source: name
        timestring: '%Y.%m.%d'
        range_from: -1
        range_to: 0
        unit: months
        exclude: True

```

If I'm running the command today, Curator will subtract a month (`2018/05/08`) then truncate/round the date (`2018/05/01`). Since I'm using `exclude: True`, every index older than `2018/05/01` will be removed.

In my case, I want to remove indices that are older than `2018/05/08`.

Of course I can use `unit: days` but in this case I will have to use either `29`, `30` or `31` days depending on how many days there's in the previous month.

Maybe we should add an option to control if we want to truncate/round the date or not ?

Does it make sense ?

Thanks,  
Guillaume

I'm using Curator 5.4.1:

```auto
$ curator --version
curator, version 5.4.1

```

---

<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:** [June 8, 2018, 3:36pm UTC](https://discuss.elastic.co/t/monthly-rolling-period-with-curator/135140/2 "2018-06-08T15:36:01Z")

</div>

What you're asking is not currently possible in Curator. You can keep entire periods with the `period` filter, but there's no way to keep 28, 30, or 31 day periods deterministically. How accurate would that be anyway? What would that actually show? The 8th of June to the 8th of May is more a month than the 8th of March back to the 8th of February?

It seems quite arbitrary. I think that the "bank standard" 30 days as month is an acceptable window with `days`, which was the original Curator use case.

However, if you wanted to do something to still make this happen, you could:

1. Use some clever shell scripting to set the `unit_count` with a shell variable.
2. Just set the time picker in Kibana to only show month day to month day periods and set `unit_count` to 32 days to always have at least 31 days.
3. Something else clever.

This just seems much more of a display-side problem than one to handle with Curator.

---

<div class="post-metadata">

**Author:** ![Mogztter](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mogztter/32/7820_2.png) [@Mogztter](https://discuss.elastic.co/u/Mogztter)\
**Post date:** [June 8, 2018, 4:59pm UTC](https://discuss.elastic.co/t/monthly-rolling-period-with-curator/135140/3 "2018-06-08T16:59:00Z")

</div>

> [@theuntergeek](#):
>
> This just seems much more of a display-side problem than one to handle with Curator.

Interesting, I think you're right 😄  
Some of our users were confused that sometimes they could browser back to the 7th or the 6th (because the previous month was only 30 or 29 days) and sometimes not.

From a cluster point of view (shards, indices, storage) it's indeed a complete nonsense to keep either 31, 30 or 29 indices depending on the month.

Thanks for your quick reply 👍

---

<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:** [July 6, 2018, 4:59pm UTC](https://discuss.elastic.co/t/monthly-rolling-period-with-curator/135140/4 "2018-07-06T16:59:04Z")

</div>

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