# Curator Delete indices based on environment variable

**URL:** <https://discuss.elastic.co/t/curator-delete-indices-based-on-environment-variable/136633>\
**Category:** Elasticsearch\
**Created:** [June 20, 2018, 8:10am UTC](https://discuss.elastic.co/t/curator-delete-indices-based-on-environment-variable/136633 "2018-06-20T08:10:34Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![tweety](https://avatars.discourse-cdn.com/v4/letter/t/51bf81/32.png) [@tweety](https://discuss.elastic.co/u/tweety)\
**Post date:** [June 20, 2018, 8:10am UTC](https://discuss.elastic.co/t/curator-delete-indices-based-on-environment-variable/136633/1 "2018-06-20T08:10:35Z")

</div>

Hi

I am trying to delete indices and want to pass unit\_count as a parameter so that we can dynamically decide the unit\_count.

{filtertype: age, source: name, direction: older, timestring: '%Y\_%m\_%d', unit: days, unit\_count: ${UNIT\_COUNT},

"", line 53, column 113:  
... %m\_%d', unit: days, unit\_count: %{UNIT\_COUNT}, exclude: null}

---

<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:** [June 20, 2018, 1:02pm UTC](https://discuss.elastic.co/t/curator-delete-indices-based-on-environment-variable/136633/2 "2018-06-20T13:02:31Z")

</div>

You haven't provided any extra context or configuration data here, so I can't guess effectively, but I'll try anyway.

> [@tweety](#):
>
> {filtertype: age, source: name, direction: older, timestring: '%Y\_%m\_%d', unit: days, unit\_count: ${UNIT\_COUNT},

This is wrapped in curly braces like JSON, but without any quotes around the keys or values. Are you trying to make a line here for `curator_cli`'s `--filter_list` argument?

---

<div class="post-metadata">

**Author:** ![tweety](https://avatars.discourse-cdn.com/v4/letter/t/51bf81/32.png) [@tweety](https://discuss.elastic.co/u/tweety)\
**Post date:** [June 21, 2018, 3:33am UTC](https://discuss.elastic.co/t/curator-delete-indices-based-on-environment-variable/136633/3 "2018-06-21T03:33:10Z")

</div>

This is a yml file. containing action. This is curator for deleting indices.

```
'5':
        action: delete_indices
        description: 'Deleting closed indices'
        options:
            ignore_empty_list: true
            timeout_override: 40000
            continue_if_exception: false
            disable_action: false
        filters:
            - {filtertype: closed, exclude: False}
            - {filtertype: pattern, kind: prefix, value: xyz_, exclude: False}
            - {filtertype: age, source: name, direction: older, timestring: '%Y_%m_%d', unit: days, unit_count: ${unit_count}, exclude: null}
```

---

<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:** [June 21, 2018, 4:28am UTC](https://discuss.elastic.co/t/curator-delete-indices-based-on-environment-variable/136633/4 "2018-06-21T04:28:52Z")

</div>

I do not think that flow-style mapping will work with environment variables. The structure should be:

```auto
filters:
  - filtertype: closed
    exclude: false
  - filtertype: pattern
    kind: prefix
    value: xyz_
    exclude: false
  - filtertype: age
    source: name
    direction: older
    timestring: '%Y_%m_%d'
    unit: days
    unit_count: ${unit_count}

```

Keep in mind that most environment variables are all caps, so if you do have one named `$unit_count`, that's fine, but typically it would be `$UNIT_COUNT`.

---

<div class="post-metadata">

**Author:** ![tweety](https://avatars.discourse-cdn.com/v4/letter/t/51bf81/32.png) [@tweety](https://discuss.elastic.co/u/tweety)\
**Post date:** [June 21, 2018, 4:59am UTC](https://discuss.elastic.co/t/curator-delete-indices-based-on-environment-variable/136633/6 "2018-06-21T04:59:45Z")

</div>

Aha...I understand your point. I used online formatter to format my file and it was running correctly unless I felt the need to add place holder ($VAR) 🙂

Thanks for helping me on this.

---

<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:** [July 19, 2018, 4:59am UTC](https://discuss.elastic.co/t/curator-delete-indices-based-on-environment-variable/136633/7 "2018-07-19T04:59:56Z")

</div>

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