# Curator rollover new\_index failing

**URL:** <https://discuss.elastic.co/t/curator-rollover-new-index-failing/150214>\
**Category:** Elasticsearch\
**Created:** [September 27, 2018, 3:02pm UTC](https://discuss.elastic.co/t/curator-rollover-new-index-failing/150214 "2018-09-27T15:02:13Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![lzukel](https://avatars.discourse-cdn.com/v4/letter/l/4491bb/32.png) [@lzukel](https://discuss.elastic.co/u/lzukel)\
**Post date:** [September 27, 2018, 3:02pm UTC](https://discuss.elastic.co/t/curator-rollover-new-index-failing/150214/1 "2018-09-27T15:02:13Z")

</div>

Curator action file:

```auto
actions:
  1:
    action: rollover
    options:
      disable_action: False
      name: index_prod_active
      new_index: "<index_prod_v1_{now/d{YYYY_MM_dd}}-1>" # have also tried "<index_prod_v1_{now/d{YYYY_MM_dd}}-000001>"
      conditions:
        max_age: 1d
        max_size: 8gb #this value is for testing purposes only

```

Message from logs:

```auto
ERROR Failed to complete action: rollover. <class 'curator.exceptions.FailedExecution'>: Exception encountered. Rerun with loglevel DEBUG and/or check Elasticsearch logs for more information. Exception: TransportError(400, 'resource_already_exists_exception', 'index [index_prod_v1_2018_09_27-1/A7OAj2mZR2u0YHuGyyzKVw] already exists')

```

Expected behavior:

1. new index created with name as such when conditions are met:

```auto
index_prod_v1_2018_09_27-2

```

I have followed the documentation [here](https://www.elastic.co/guide/en/elasticsearch/client/curator/5.5/option_new_index.html)  
I have read through [this forum post](https://discuss.elastic.co/t/how-can-i-name-curator-rollover-new-index-like-date-prefix-yyyy-mm-dd-1/128542)  
ES version - 6.2.3  
Curator version - 5.5.4  
I need to keep indices arranged by date, but I am also trying to keep shard sizes down to around ~20GB when all is said and done.

---

<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:** [September 27, 2018, 4:06pm UTC](https://discuss.elastic.co/t/curator-rollover-new-index-failing/150214/2 "2018-09-27T16:06:55Z")

</div>

The problem you are encountering is because you're manually specifying the target index, and it's the same timestamp as the current day. Besides which, when you manually specify the `-1` at the end, it can't auto-increment.

Allow me to demonstrate. I made this index down to the second to show the date rollover, using `<index_prod_v1_{now/s{YYYY_MM_dd_HH_mm_ss}}-1>`. You must [url encode](https://www.urlencoder.org) the date\_math when using Console (but not in Curator—it handles it for you).

```auto
PUT /%3Cindex_prod_v1_%7Bnow%2Fs%7BYYYY_MM_dd_HH_mm_ss%7D%7D-1%3E
{
  "aliases": {
    "index_prod_active": {}
  }
}

```

yields:

```auto
{
  "acknowledged": true,
  "shards_acknowledged": true,
  "index": "index_prod_v1_2018_09_27_15_55_33-1"
}

```

(Note: UTC time)

Subsequently, if I run:

```auto
POST /index_prod_active/_rollover 
{
  "conditions": {
    "max_age": "1s"
  }
}

```

I see:

```auto
{
  "acknowledged": true,
  "shards_acknowledged": true,
  "old_index": "index_prod_v1_2018_09_27_15_55_33-1",
  "new_index": "index_prod_v1_2018_09_27_15_57_04-000002",
  "rolled_over": true,
  "dry_run": false,
  "conditions": {
    "[max_age: 1s]": true
  }
}

```

See how it incremented both the date stamp in the index name _and_ the version number at the end? And that I didn't need to specify a target index name?

You can do likewise by creating the index & alias with the timestring in the original index creation, and then you won't have to worry about specifying the target index name. [Rollover has you covered for `date_math` automatically](https://www.elastic.co/guide/en/elasticsearch/reference/6.4/indices-rollover-index.html#_using_date_math_with_the_rollover_api).

If you _do_ feel it necessary to manually name the target indices, I suggest adding date\_math down to (at least) the hour and minute in your target index name, and omit the `-1` at the end. This will ensure that the old index name and new index name will not collide (unless you try to rollover 2x in 1 minute).

---

<div class="post-metadata">

**Author:** ![lzukel](https://avatars.discourse-cdn.com/v4/letter/l/4491bb/32.png) [@lzukel](https://discuss.elastic.co/u/lzukel)\
**Post date:** [September 27, 2018, 4:12pm UTC](https://discuss.elastic.co/t/curator-rollover-new-index-failing/150214/3 "2018-09-27T16:12:32Z")

</div>

Thank you that explained exactly what I was missing, it would be so very helpful if that information was in the docs.

---

<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:** [September 27, 2018, 4:16pm UTC](https://discuss.elastic.co/t/curator-rollover-new-index-failing/150214/4 "2018-09-27T16:16:19Z")

</div>

[It _is_ in the docs](https://www.elastic.co/guide/en/elasticsearch/reference/6.4/indices-rollover-index.html#_using_date_math_with_the_rollover_api). It's just not as spelled out as clearly as I just did.

Particularly, it's in the `1` and `2`, blue-circle explanations under the code block:

> 1 Creates an index named with today’s date (e.g.) `logs-2016.10.31-1`  
> 2 Rolls over to a new index with today’s date, e.g. `logs-2016.10.31-000002` if run immediately, or `logs-2016.11.01-000002` if run after 24 hours

---

<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:** [October 25, 2018, 4:30pm UTC](https://discuss.elastic.co/t/curator-rollover-new-index-failing/150214/5 "2018-10-25T16:30:15Z")

</div>

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