# Curator \_alias is created for all the indices rather than specified?

**URL:** <https://discuss.elastic.co/t/curator--alias-is-created-for-all-the-indices-rather-than-specified/80905>\
**Category:** Elasticsearch\
**Created:** [April 1, 2017, 7:46pm UTC](https://discuss.elastic.co/t/curator--alias-is-created-for-all-the-indices-rather-than-specified/80905 "2017-04-01T19:46:42Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Yaswanth](https://avatars.discourse-cdn.com/v4/letter/y/94ad74/32.png) [@Yaswanth](https://discuss.elastic.co/u/Yaswanth)\
**Post date:** [April 1, 2017, 7:46pm UTC](https://discuss.elastic.co/t/curator--alias-is-created-for-all-the-indices-rather-than-specified/80905/1 "2017-04-01T19:46:42Z")

</div>

HI,

I created alias for indices that are in april , When i ran the command i got response like this:

```
2017-04-02 00:46:53,374 INFO Preparing Action ID: 1, "alias"
2017-04-02 00:46:53,389 INFO Trying Action ID: 1, "alias": Creating alias for apr month.
2017-04-02 00:46:53,411 INFO Updating aliases...
2017-04-02 00:46:53,411 INFO Alias actions: {'actions': [{'add': {'alias': 'apr_alias', 'index': 'data-sep-2017-09-01'}}, {'add': {'alias': 'apr_alias', 'index': 'data-july-2017-07-01'}}, {'add': {'alias': 'apr_alias', 'index': 'data-june-2017-06-01'}}, {'add': {'alias': 'apr_alias', 'index': 'data-dec-2017-12-01'}}, {'add': {'alias': 'apr_alias', 'index': 'data-august-2017-08-01'}}, {'add': {'alias': 'apr_alias', 'index': 'data-may-2017-05-01'}}, {'add': {'alias': 'apr_alias', 'index': 'data-apr-2017-04-01'}}, {'add': {'alias': 'apr_alias', 'index': 'data-oct-2017-10-01'}}, {'add': {'alias': 'apr_alias', 'index': 'data-nov-2017-11-01'}}, {'remove': {'alias': 'apr_alias', 'index': 'data-sep-2017-09-01'}}, {'remove': {'alias': 'apr_alias', 'index': 'data-july-2017-07-01'}}, {'remove': {'alias': 'apr_alias', 'index': 'data-june-2017-06-01'}}, {'remove': {'alias': 'apr_alias', 'index': 'data-dec-2017-12-01'}}, {'remove': {'alias': 'apr_alias', 'index': 'data-august-2017-08-01'}}, {'remove': {'alias': 'apr_alias', 'index': 'data-may-2017-05-01'}}, {'remove': {'alias': 'apr_alias', 'index': 'data-oct-2017-10-01'}}, {'remove': {'alias': 'apr_alias', 'index': 'data-nov-2017-11-01'}}]}
2017-04-02 00:46:53,774 INFO Action ID: 1, "alias" completed.
2017-04-02 00:46:53,774 INFO Job completed.

```

In the above response first it had added index to apr\_alias and removed some indices except for the index that created on april(i.e .data-apr-2017-04-01). This is good that is what i want?

But when i checked `GET _aliases` command in sense plugin i see that the apr\_aliases is created for every index rather than creating for the particular index(i.e.data-apr-2017-04-01).It is like this..

```
{
   "data-july-2017-07-01": {
      "aliases": {
         "apr_alias": {}
      }
   },
   "data-dec-2017-12-01": {
      "aliases": {
         "apr_alias": {}
      }
   },
   "data-june-2017-06-01": {
      "aliases": {
         "apr_alias": {}
      }
   },
   "data-jan-2017-01-01": {
      "aliases": {
         "jan_alias": {}
      }
   },
   "data-sep-2017-09-01": {
      "aliases": {
         "apr_alias": {}
      }
   },
   "data-nov-2017-11-01": {
      "aliases": {
         "apr_alias": {}
      }
   },
   "data-oct-2017-10-01": {
      "aliases": {
         "apr_alias": {}
      }
   },
   "data-feb-2017-02-01": {
      "aliases": {
         "feb_alias": {}
      }
   },
   "data-may-2017-05-01": {
      "aliases": {
         "apr_alias": {}
      }
   },
   "data-apr-2017-04-01": {
      "aliases": {
         "apr_alias": {}
      }
   },
   "data-august-2017-08-01": {
      "aliases": {
         "apr_alias": {}
      }
   },
   "data-mar-2017-03-01": {
      "aliases": {
         "mar_alias": {}
      }
   }
}

```

MAY I know why this is happening?

THANKS

---

<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:** [April 1, 2017, 8:23pm UTC](https://discuss.elastic.co/t/curator--alias-is-created-for-all-the-indices-rather-than-specified/80905/2 "2017-04-01T20:23:24Z")

</div>

Though the operation is atomic, if you have the same index being added and removed, it will be added. This is because the removes are parsed first. I can clearly see in your output that there are adds for those indices, so they persist.

It would also be helpful if you included your configuration.

---

<div class="post-metadata">

**Author:** ![Yaswanth](https://avatars.discourse-cdn.com/v4/letter/y/94ad74/32.png) [@Yaswanth](https://discuss.elastic.co/u/Yaswanth)\
**Post date:** [April 2, 2017, 5:28am UTC](https://discuss.elastic.co/t/curator--alias-is-created-for-all-the-indices-rather-than-specified/80905/3 "2017-04-02T05:28:54Z")

</div>

Thanks..

My requirement is like this i need to create an alias for every month(i.e. jan\_alias, feb\_alias etc ) automatically since it cannot be done in index template i am coming to curator, even in curator too i have to run it for every month.

For testing purpose i had created the indices at every start date of every month(i.e.data-jan-2017-01-01,data-feb-2017-02-01 etc) as i mentioned above. For creating alias for `data-jan-2017-01-01` i used only two filters keeping older and younger in such a way getting the in between days as i mentioned below:

```
- filtertype: age
        source: name
        direction: older
        timestring: '%Y-%m-%d'
        unit: days
        unit_count: 60
        exclude:
      - filtertype: age
        source: name
        direction: younger
        timestring: '%Y-%m-%d'
        unit: days
        unit_count: 91
        exclude:

```

Similarly i did for data-feb-2017-02-01,data-mar-2017-03-01. But for data-apr-2017-04-01 i used the below config like this:

```
actions:
  1:
    action: alias
    description: >-
      Creating alias for apr month.
    options:
      name: apr_alias
      extra_settings:
      timeout_override:
      continue_if_exception: False
      disable_action: False
    add:
      filters:
      - filtertype: pattern
        kind: prefix
        value: data-
        exclude:
      - filtertype: age
        source: name
        direction: younger
        timestring: '%Y-%m-%d'
        unit: days
        unit_count: 2
        exclude:
    remove:
      filters:
      - filtertype: pattern
        kind: prefix
        value: data-
      - filtertype: age
        source: name
        direction: younger
        timestring: '%Y-%m-%d'
        unit: days
        unit_count: 0
        exclude:

```

For the above config, it first adding apr\_alias to all the indices and removing it except for `data-apr-2017-04-01` . Since you said `removes are parsed first` . I don't know how to overcome this? Similarly i have to do it for `data-may-2017-05-01`,`data-jun-2017-06-01` etc , i don't know how to filter them since i can use only younger filter on them.

Any help is highly appreciated..

Thanks

---

<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:** [April 3, 2017, 2:58pm UTC](https://discuss.elastic.co/t/curator--alias-is-created-for-all-the-indices-rather-than-specified/80905/4 "2017-04-03T14:58:36Z")

</div>

Curator is not going to be a terrific choice for creating aliases for a monthly block of indices, at least not until [#733](https://github.com/elastic/curator/issues/733) is implemented.

---

<div class="post-metadata">

**Author:** ![Yaswanth](https://avatars.discourse-cdn.com/v4/letter/y/94ad74/32.png) [@Yaswanth](https://discuss.elastic.co/u/Yaswanth)\
**Post date:** [April 3, 2017, 3:19pm UTC](https://discuss.elastic.co/t/curator--alias-is-created-for-all-the-indices-rather-than-specified/80905/5 "2017-04-03T15:19:57Z")

</div>

Thanks for your confirmation on that. It really helped..

What will be the best choice for the above usecase?

Thanks

---

<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:** [May 1, 2017, 3:20pm UTC](https://discuss.elastic.co/t/curator--alias-is-created-for-all-the-indices-rather-than-specified/80905/6 "2017-05-01T15:20:00Z")

</div>

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

---

<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:** [May 2, 2017, 12:34am UTC](https://discuss.elastic.co/t/curator--alias-is-created-for-all-the-indices-rather-than-specified/80905/7 "2017-05-02T00:34:17Z")

</div>

#733 was implemented in Curator 5.0, which has since been released.
