# Index Alias for rotating time based indices

**URL:** <https://discuss.elastic.co/t/index-alias-for-rotating-time-based-indices/176743>\
**Category:** Elasticsearch\
**Tags:** ilm-index-lifecycle-management\
**Created:** [April 13, 2019, 5:16pm UTC](https://discuss.elastic.co/t/index-alias-for-rotating-time-based-indices/176743 "2019-04-13T17:16:26Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![justinw](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/justinw/32/40277_2.png) [@justinw](https://discuss.elastic.co/u/justinw)\
**Post date:** [April 13, 2019, 5:16pm UTC](https://discuss.elastic.co/t/index-alias-for-rotating-time-based-indices/176743/1 "2019-04-13T17:16:27Z")

</div>

Hi,

The docs here ([https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-aliases.html](https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-aliases.html)) are pretty explicit in that something like this:

```auto
POST /_aliases
{
    "actions" : [
        { "add" : { "index" : "test*", "alias" : "all_test_indices" } }
    ]
}

```

will not automatically update to include new indices that match.

If I'm using ILM or time based indices (filebeat, metricbeat) would I need to re-add this alias every time a new index is created, or is there a feature of ILM that would do this on my behalf? Right now I'm thinking the only way to do this would be a cronjob to update the alias on a schedule, or query for new indices and update when a new one is found.

Thanks,  
Justin

---

<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:** [April 15, 2019, 10:06pm UTC](https://discuss.elastic.co/t/index-alias-for-rotating-time-based-indices/176743/2 "2019-04-15T22:06:46Z")

</div>

> [@justinw](#):
>
> If I'm using ILM or time based indices (filebeat, metricbeat) would I need to re-add this alias every time a new index is created, or is there a feature of ILM that would do this on my behalf? Right now I'm thinking the only way to do this would be a cronjob to update the alias on a schedule, or query for new indices and update when a new one is found.

If you are talking about rollover within an ILM policy, then the rollover action will update the alias automatically, you don't need to do that yourself.

---

<div class="post-metadata">

**Author:** ![justinw](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/justinw/32/40277_2.png) [@justinw](https://discuss.elastic.co/u/justinw)\
**Post date:** [April 22, 2019, 9:52pm UTC](https://discuss.elastic.co/t/index-alias-for-rotating-time-based-indices/176743/3 "2019-04-22T21:52:34Z")

</div>

Hi @dakrone,

To clarify, will it also update additional read only aliases, or just the write index ("is\_write\_index": true)?

For example, if I create the index like so, I'd want metrics-teamA and metrics-teamB to stay up to date when the index is eventually rolled to metrics-6.7.1-000002.

```auto
PUT metrics-6.7.1-000001
{
  "aliases": {
    "metrics-6.7.1": {
      "is_write_index": true
    },
    "metrics-teamA": {
      "filter": {
        "term": {
          "team": "A"
        }
      }
    },
    "metrics-teamB": {
      "filter": {
        "term": {
          "team": "B"
        }
      }
    }
  }
}

```

Thanks, Justin

---

<div class="post-metadata">

**Author:** ![justinw](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/justinw/32/40277_2.png) [@justinw](https://discuss.elastic.co/u/justinw)\
**Post date:** [May 9, 2019, 11:46pm UTC](https://discuss.elastic.co/t/index-alias-for-rotating-time-based-indices/176743/5 "2019-05-09T23:46:30Z")

</div>

For those reading this later on, if you include aliases on the index template, then they will be applied to future rollover indices as well as any indices created with the ilm shrink operation.

```auto
PUT _template/template_1
{
    "index_patterns" : ...
    "settings" : {
        ...
    },
    "aliases" : {
        "alias1" : {},
        "{index}-alias" : {} 
    }
}

```

---

<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:** [June 6, 2019, 11:55pm UTC](https://discuss.elastic.co/t/index-alias-for-rotating-time-based-indices/176743/6 "2019-06-06T23:55:11Z")

</div>

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