# Rollover Policy Not reacting to Number of Docs

**URL:** <https://discuss.elastic.co/t/rollover-policy-not-reacting-to-number-of-docs/212213>\
**Category:** Elasticsearch\
**Tags:** ilm-index-lifecycle-management\
**Created:** [December 17, 2019, 6:44pm UTC](https://discuss.elastic.co/t/rollover-policy-not-reacting-to-number-of-docs/212213 "2019-12-17T18:44:36Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![cawoodm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/cawoodm/32/14083_2.png) [@cawoodm](https://discuss.elastic.co/u/cawoodm)\
**Post date:** [December 17, 2019, 6:44pm UTC](https://discuss.elastic.co/t/rollover-policy-not-reacting-to-number-of-docs/212213/1 "2019-12-17T18:44:36Z")

</div>

We have an index lifecycle policy which we have set to `maxdocs=5` just to see what happens.

```auto
{
    "dev-policy": {
        "version": 2,
        "modified_date": "2019-12-17T10:14:34.142Z",
        "policy": {
            "phases": {
                "hot": {
                    "min_age": "0ms",
                    "actions": {
                        "rollover": {
                            "max_age": "1d",
                            "max_docs": 5
                        }
                    }
                },
                "delete": {
                    "min_age": "180d",
                    "actions": {
                        "delete": {}
                    }
                }
            }
        }
    }
}

```

Here is the index assigned to that policy:

```auto
{
    "access-dev00003": {
        "aliases": {
            "access-dev": {
                "is_write_index": true
            }
        },
        "mappings": {
            ...
        },
        "settings": {
            "index": {
                "lifecycle": {
                    "name": "dev_policy",
                    "rollover_alias": "access-dev"
                },
                "number_of_shards": "1",
                "provided_name": "access-dev00003",
                "creation_date": "1576579441268",
                "number_of_replicas": "0",
                "uuid": "58hR5Nh9SqmfHEvDLkVhJg",
                "version": {
                    "created": "7030099"
                }
            }
        }
    }
}

```

I would expect a new index `access-dev00004` to be created when the index exceeds 5 documents but this does not happen:

```auto
health status index uuid pri rep docs.count docs.deleted store.size pri.store.size
green open access-dev2 _2Hp-oiMRb-bhXbsXzoftw 1 0 6611337 1423565 830.7mb 830.7mb
green open access-dev00003 58hR5Nh9SqmfHEvDLkVhJg 1 0 30 0 439.6kb 439.6kb

```

---

<div class="post-metadata">

**Author:** ![cawoodm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/cawoodm/32/14083_2.png) [@cawoodm](https://discuss.elastic.co/u/cawoodm)\
**Post date:** [December 17, 2019, 6:49pm UTC](https://discuss.elastic.co/t/rollover-policy-not-reacting-to-number-of-docs/212213/2 "2019-12-17T18:49:50Z")

</div>

Also "Linked Indices" in Kibana remains stubbornly at 0.

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/0/a/0ae020c9435208a7d8d834b46ac16e4585768239.png)

---

<div class="post-metadata">

**Author:** ![cawoodm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/cawoodm/32/14083_2.png) [@cawoodm](https://discuss.elastic.co/u/cawoodm)\
**Post date:** [December 17, 2019, 6:50pm UTC](https://discuss.elastic.co/t/rollover-policy-not-reacting-to-number-of-docs/212213/3 "2019-12-17T18:50:54Z")

</div>

Our template `access-dev`:

```auto
{
    "access-dev": {
        "order": 0,
        "index_patterns": [
            "access-dev*"
        ],
        "settings": {
            "index": {
                "lifecycle": {
                    "name": "dev-policy",
                    "rollover_alias": "access-dev"
                },
                "number_of_shards": "1",
                "number_of_replicas": "0"
            }
        },
        "mappings": {
...

```

---

<div class="post-metadata">

**Author:** ![dakrone](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dakrone/32/23351_2.png) [@dakrone](https://discuss.elastic.co/u/dakrone)\
**Post date:** [December 18, 2019, 10:16pm UTC](https://discuss.elastic.co/t/rollover-policy-not-reacting-to-number-of-docs/212213/4 "2019-12-18T22:16:13Z")

</div>

How long are you waiting? By default the poll interval is 10 minutes (this can be changed), so even if you index 5+ documents, it will only check every 10 minutes.

---

<div class="post-metadata">

**Author:** ![cawoodm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/cawoodm/32/14083_2.png) [@cawoodm](https://discuss.elastic.co/u/cawoodm)\
**Post date:** [December 19, 2019, 7:34am UTC](https://discuss.elastic.co/t/rollover-policy-not-reacting-to-number-of-docs/212213/5 "2019-12-19T07:34:40Z")

</div>

We've waited a few days with no rollover. We're missing the entire rollover - at least `1d` should have triggered by now:

```auto
"rollover": {
    "max_age": "1d",
    "max_docs": 5
}

```

---

<div class="post-metadata">

**Author:** ![dakrone](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dakrone/32/23351_2.png) [@dakrone](https://discuss.elastic.co/u/dakrone)\
**Post date:** [December 19, 2019, 2:54pm UTC](https://discuss.elastic.co/t/rollover-policy-not-reacting-to-number-of-docs/212213/6 "2019-12-19T14:54:43Z")

</div>

Okay let's find out why it's not rolling over, what's the output of:

```auto
GET /access-dev00003/_ilm/explain?human

```

---

<div class="post-metadata">

**Author:** ![cawoodm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/cawoodm/32/14083_2.png) [@cawoodm](https://discuss.elastic.co/u/cawoodm)\
**Post date:** [December 19, 2019, 3:04pm UTC](https://discuss.elastic.co/t/rollover-policy-not-reacting-to-number-of-docs/212213/7 "2019-12-19T15:04:59Z")

</div>

```auto
{
    "indices": {
        "access-dev00003": {
            "index": "access-dev00003",
            "managed": true,
            "policy": "dev_policy",
            "step_info": {
                "type": "illegal_argument_exception",
                "reason": "policy [dev_policy] does not exist"
            }
        }
    }
}

```

So it looks like a `_` instead of `-` typo. To repair:

```auto
POST /access-dev00003/_settings
{
    "index": {
        "lifecycle": {
            "name": "dev-policy",
            "rollover_alias": "access-dev"
        }
    }
}

```

And `explain?human` now returns:

```auto
{
    "indices": {
        "access-dev00003": {
            "index": "access-dev00003",
            "managed": true,
            "policy": "dev-policy",
            "lifecycle_date": "2019-12-17T10:44:01.268Z",
            "lifecycle_date_millis": 1576579441268,
            "phase": "hot",
            "phase_time": "2019-12-19T15:02:27.505Z",
            "phase_time_millis": 1576767747505,
            "action": "unfollow",
            "action_time": "2019-12-19T15:02:27.505Z",
            "action_time_millis": 1576767747505,
            "step": "wait-for-follow-shard-tasks",
            "step_time": "2019-12-19T15:02:27.536Z",
            "step_time_millis": 1576767747536,
            "phase_execution": {
                "policy": "dev-policy",
                "phase_definition": {
                    "min_age": "0ms",
                    "actions": {
                        "rollover": {
                            "max_age": "1d",
                            "max_docs": 5
                        }
                    }
                },
                "version": 2,
                "modified_date": "2019-12-17T10:14:34.142Z",
                "modified_date_in_millis": 1576577674142
            }
        }
    }
}

```

---

<div class="post-metadata">

**Author:** ![cawoodm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/cawoodm/32/14083_2.png) [@cawoodm](https://discuss.elastic.co/u/cawoodm)\
**Post date:** [December 19, 2019, 3:15pm UTC](https://discuss.elastic.co/t/rollover-policy-not-reacting-to-number-of-docs/212213/8 "2019-12-19T15:15:05Z")

</div>

What is interesting is that I used Kibana's "Index Lifecycle Policies" UI to assign the index to the policy and it's not bringing any error but obviously not linking the index.

It's kinda confusing since it lists "indexes" attached to the policy but when you add stuff it's the "index template" and not the index you are adding...

---

<div class="post-metadata">

**Author:** ![dakrone](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dakrone/32/23351_2.png) [@dakrone](https://discuss.elastic.co/u/dakrone)\
**Post date:** [December 19, 2019, 4:14pm UTC](https://discuss.elastic.co/t/rollover-policy-not-reacting-to-number-of-docs/212213/9 "2019-12-19T16:14:30Z")

</div>

> [@cawoodm](#):
>
> What is interesting is that I used Kibana's "Index Lifecycle Policies" UI to assign the index to the policy and it's not bringing any error but obviously not linking the index.
> 
> It's kinda confusing since it lists "indexes" attached to the policy but when you add stuff it's the "index template" and not the index you are adding...

I'm not as familiar with the Kibana UI side of things, but this does sound like either a bug or at least a usability issue. I would recommend opening an issue on the [GitHub - elastic/kibana: Your window into the Elastic Stack](https://github.com/elastic/kibana/) repository to make this easier/better.

---

<div class="post-metadata">

**Author:** ![rugenl](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rugenl/32/12887_2.png) [@rugenl](https://discuss.elastic.co/u/rugenl)\
**Post date:** [December 19, 2019, 4:42pm UTC](https://discuss.elastic.co/t/rollover-policy-not-reacting-to-number-of-docs/212213/10 "2019-12-19T16:42:23Z")

</div>

You have dev-policy in some places and dev\_policy in another.

---

<div class="post-metadata">

**Author:** ![cawoodm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/cawoodm/32/14083_2.png) [@cawoodm](https://discuss.elastic.co/u/cawoodm)\
**Post date:** [December 19, 2019, 10:01pm UTC](https://discuss.elastic.co/t/rollover-policy-not-reacting-to-number-of-docs/212213/11 "2019-12-19T22:01:09Z")

</div>

I've fixed that now (as I posted above) and I am still seeing no rollover.  
My expectation is that a new index `access-dev00004` should be created but everything is still merrily logging to `access-dev00003`.

Can I ask: how does ES know to create `access-dev00004`? Does it parse `access-dev00003` and figure out the numbering system?

---

<div class="post-metadata">

**Author:** ![dakrone](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dakrone/32/23351_2.png) [@dakrone](https://discuss.elastic.co/u/dakrone)\
**Post date:** [December 19, 2019, 11:32pm UTC](https://discuss.elastic.co/t/rollover-policy-not-reacting-to-number-of-docs/212213/12 "2019-12-19T23:32:26Z")

</div>

> [@cawoodm](#):
>
> Can I ask: how does ES know to create `access-dev00004` ? Does it parse `access-dev00003` and figure out the numbering system?

It does. However, you index name does not actually follow the pattern rollover uses. In order for rollover to work, it needs to end in `-\d+` (a hyphen preceding the numbers), so you should name your index `access-dev-000003` (or whatever number).

I suspect that if you check the ILM explain output it will be in an error state due to the name being invalid for rollover.

---

<div class="post-metadata">

**Author:** ![rugenl](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rugenl/32/12887_2.png) [@rugenl](https://discuss.elastic.co/u/rugenl)\
**Post date:** [December 20, 2019, 3:41am UTC](https://discuss.elastic.co/t/rollover-policy-not-reacting-to-number-of-docs/212213/13 "2019-12-20T03:41:19Z")

</div>

> [@cawoodm](#):
>
> Can I ask: how does ES know to create `access-dev00004` ? Does it parse `access-dev00003` and figure out the numbering system?

I think it uses index.provided\_name, that is how things like ...-{now/d}-.... get saved.

I agree with the prior post, I think indices need to end in -000000 pattern.

---

<div class="post-metadata">

**Author:** ![cawoodm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/cawoodm/32/14083_2.png) [@cawoodm](https://discuss.elastic.co/u/cawoodm)\
**Post date:** [December 20, 2019, 7:35pm UTC](https://discuss.elastic.co/t/rollover-policy-not-reacting-to-number-of-docs/212213/14 "2019-12-20T19:35:13Z")

</div>

OK, switched to logs-dev-00001 and, after 10min nothing and then... 14min later I see the new index being automatically created.

Thanks all!

---

<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:** [January 17, 2020, 7:35pm UTC](https://discuss.elastic.co/t/rollover-policy-not-reacting-to-number-of-docs/212213/15 "2020-01-17T19:35:13Z")

</div>

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