# Unable to automatize rollover using "index templates"

**URL:** <https://discuss.elastic.co/t/unable-to-automatize-rollover-using-index-templates/218064>\
**Category:** Elasticsearch\
**Created:** [February 5, 2020, 11:11pm UTC](https://discuss.elastic.co/t/unable-to-automatize-rollover-using-index-templates/218064 "2020-02-05T23:11:45Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![pispo](https://avatars.discourse-cdn.com/v4/letter/p/ecc23a/32.png) [@pispo](https://discuss.elastic.co/u/pispo)\
**Post date:** [February 5, 2020, 11:11pm UTC](https://discuss.elastic.co/t/unable-to-automatize-rollover-using-index-templates/218064/1 "2020-02-05T23:11:45Z")

</div>

Hi,

The indices of my ES cluster are structured as follows:

```auto
deviceA-2018 (size 5gb)
deviceA-2019 (size 1gb)
deviceB-2019 (size 100gb)

```

The deviceIDs are dynamic and unknown a priori and the indices sizes vary too much between them.

For automatization of index creation I am using "index templates" (e.g. set number of shards). This mechanism is very convenient because the indexation is made via Apache Storm and I do not need to take care of the existance of the index; if it does not exists, it is created with the template settings and if exists, the data is indexed directly.

```auto
PUT _template/device_template
{
  "index_patterns": ["*-*"],
  "settings": {
    "number_of_shards": 5
  },
  ...
}

```

For performance reasons I am restricting the max size of an index using "rollover" functionality.

```auto
PUT _ilm/policy/device_policy
{
  "policy": {
    "phases": {
      "hot": {
        "actions": {
          "rollover": {
            "max_size": "30GB"
          }
        }
      }
    }
  }
}
PUT _template/deviceA_template
{
  "index_patterns": ["deviceA-2019-*"],
  "settings": {
    "number_of_shards": 5
  },
  "settings": {
    "index.lifecycle.name": "device_policy",
    "index.lifecycle.rollover_alias": "deviceA-2019"
  }
  ...
}
PUT deviceA-2019-000001
{
  "aliases": {
    "deviceA-2019": {
      "is_write_index": true
    }
  }
}

```

My problem is that I cannot use these two features in conjuction in an automatic way. The configuration that I tried to use but does not work is:

```auto
PUT _template/device_template
{
  "index_patterns": ["*-*-000001"],
  "settings": {
    "number_of_shards": 5
  },
  "settings": {
    "index.lifecycle.name": "device_policy",
    "index.lifecycle.rollover_alias": "{indexWITHOUTrolloverID}" //e.g. deviceA-2019
  },
 "aliases": {
    "{indexWITHOUTrolloverID}": { //e.g. deviceA-2019
      "is_write_index": true
    }
  }
  ...
}

PUT _template/device_template
{
  "index_patterns": ["*-*-!00001"],
  "settings": {
    "number_of_shards": 5
  },
  "settings": {
    "index.lifecycle.name": "device_policy",
    "index.lifecycle.rollover_alias": "{indexWITHOUTrolloverID}" //e.g. deviceA-2019
  },
  ...
}

```

The problem that appears in this issue is very similar to my problem ([https://github.com/elastic/kibana/issues/27967](https://github.com/elastic/kibana/issues/27967)). Notice that this issue appears in kibana repo but it it is not related with kibana but with elasticsearch.

Is there any way to do delegate the creation of a index on demand by ElasticSearch with rollover enabled?

Thank you for your help!

---

<div class="post-metadata">

**Author:** ![HenningAndersen](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/henningandersen/32/48188_2.png) [@HenningAndersen](https://discuss.elastic.co/u/HenningAndersen)\
**Post date:** [February 6, 2020, 12:07pm UTC](https://discuss.elastic.co/t/unable-to-automatize-rollover-using-index-templates/218064/2 "2020-02-06T12:07:39Z")

</div>

Hi @pispo,

I am afraid not at present. Setting up the alias and index for use with ilm is a bit cumbersome as described in: [https://github.com/elastic/elasticsearch/issues/42245](https://github.com/elastic/elasticsearch/issues/42245).

You have to setup the first index and alias manually (or in your integration with Elasticsearch) for 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 5, 2020, 12:10pm UTC](https://discuss.elastic.co/t/unable-to-automatize-rollover-using-index-templates/218064/3 "2020-03-05T12:10:57Z")

</div>

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