# ILM policy not working for all indexes

**URL:** <https://discuss.elastic.co/t/ilm-policy-not-working-for-all-indexes/216792>\
**Category:** Elasticsearch\
**Tags:** ilm-index-lifecycle-management\
**Created:** [January 28, 2020, 9:23am UTC](https://discuss.elastic.co/t/ilm-policy-not-working-for-all-indexes/216792 "2020-01-28T09:23:38Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![SergeSpinoza](https://avatars.discourse-cdn.com/v4/letter/s/c5a1d2/32.png) [@SergeSpinoza](https://discuss.elastic.co/u/SergeSpinoza)\
**Post date:** [January 28, 2020, 9:23am UTC](https://discuss.elastic.co/t/ilm-policy-not-working-for-all-indexes/216792/1 "2020-01-28T09:23:38Z")

</div>

Hi! At some point ILM stopped working for all indexes.

For example - ILM policy for index nginx-\*:

GET /\_ilm/policy/nginx\_index\_delete:

```
{
  "nginx_index_delete": {
    "policy": {
      "phases": {
        "hot": {
          "actions": {
            "set_priority": {
              "priority": 100
            }
          },
          "min_age": "0ms"
        },
        "delete": {
          "actions": {
            "delete": {}
          },
          "min_age": "16d"
        }
      }
    },
    "modified_date": "2020-01-22T10:06:20.292Z",
    "version": 2
  }
}

```

But old indexes of nginx-\* do not deleted automatically.

GET nginx-2020.01.11/\_ilm/explain:

```
{
  "indices": {
    "nginx-2020.01.11": {
      "index": "nginx-2020.01.11",
      "managed": true,
      "phase_execution": {
        "policy": "nginx_index_delete",
        "modified_date_in_millis": 1574062458159,
        "phase_definition": {
          "actions": {
            "set_priority": {
              "priority": 100
            }
          },
          "min_age": "0ms"
        },
        "version": 1
      },
      "action_time_millis": 1578700802422,
      "step_time_millis": 1578700802422,
      "phase_time_millis": 1578700801973,
      "phase": "hot",
      "step": "complete",
      "lifecycle_date_millis": 1578700801243,
      "policy": "nginx_index_delete",
      "action": "complete"
    }
  }
}

```

GET \_template/nginx:

```
{
  "nginx": {
    "mappings": {
      "doc": {
        "properties": {
          "request_time": {
            "type": "float"
          },
          "upstream_port": {
            "type": "float"
          },
          "geoip": {
            "dynamic": true,
            "properties": {
              "latitude": {
                "type": "half_float"
              },
              "ip": {
                "type": "ip"
              },
              "location": {
                "type": "geo_point"
              },
              "longitude": {
                "type": "half_float"
              }
            }
          },
          "@timestamp": {
            "type": "date"
          },
          "bytes": {
            "type": "float"
          },
          "upstream_response_time": {
            "type": "float"
          },
          "upstream_addr": {
            "type": "ip"
          },
          "@version": {
            "type": "keyword"
          },
          "response": {
            "type": "float"
          },
          "clientip": {
            "type": "ip"
          }
        },
        "dynamic_templates": [
          {
            "message_field": {
              "path_match": "message",
              "mapping": {
                "norms": false,
                "type": "text"
              },
              "match_mapping_type": "string"
            }
          },
          {
            "string_fields": {
              "match_mapping_type": "string",
              "mapping": {
                "norms": false,
                "fields": {
                  "keyword": {
                    "ignore_above": 256,
                    "type": "keyword"
                  }
                },
                "type": "text"
              },
              "match": "*"
            }
          }
        ]
      }
    },
    "settings": {
      "index": {
        "number_of_replicas": "1",
        "number_of_shards": "1",
        "lifecycle": {
          "name": "nginx_index_delete"
        },
        "refresh_interval": "5s"
      }
    },
    "version": 60001,
    "index_patterns": [
      "nginx-*"
    ],
    "order": 0,
    "aliases": {}
  }
}

```

What can this problem be associated, that the ILM is not work for all indexes?

Thanks!

---

<div class="post-metadata">

**Author:** ![RichieJarvis](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/richiejarvis/32/42425_2.png) [@RichieJarvis](https://discuss.elastic.co/u/RichieJarvis)\
**Post date:** [January 28, 2020, 4:47pm UTC](https://discuss.elastic.co/t/ilm-policy-not-working-for-all-indexes/216792/2 "2020-01-28T16:47:54Z")

</div>

Hi Serge,

It looks like your existing (old) indices are using version 1 of the ILM Policy, which does not have a delete phase. You can see the current ILM policy being applied in your output of `GET nginx-2020.01.11/_ilm/explain`. The important section is this:

```auto
        "policy": "nginx_index_delete",
        "modified_date_in_millis": 1574062458159,
        "phase_definition": {
          "actions": {
            "set_priority": {
              "priority": 100
            }
          },
          "min_age": "0ms"
        },
        "version": 1
      },

```

As you can see, version 1 is still in-use by this index. In order to change it to use version 2, you should reapply the ILM settings to the relevant indices using the ILM API to remove the policy: [https://www.elastic.co/guide/en/elasticsearch/reference/current/ilm-remove-policy.html](https://www.elastic.co/guide/en/elasticsearch/reference/current/ilm-remove-policy.html) and then readd using the Settings API, as shown here:[https://www.elastic.co/guide/en/elasticsearch/reference/current/\_switching\_policies\_for\_an\_index.html](https://www.elastic.co/guide/en/elasticsearch/reference/current/_switching_policies_for_an_index.html)

Hope that helps.

Cheers,

Richie

---

<div class="post-metadata">

**Author:** ![SergeSpinoza](https://avatars.discourse-cdn.com/v4/letter/s/c5a1d2/32.png) [@SergeSpinoza](https://discuss.elastic.co/u/SergeSpinoza)\
**Post date:** [January 29, 2020, 9:21am UTC](https://discuss.elastic.co/t/ilm-policy-not-working-for-all-indexes/216792/3 "2020-01-29T09:21:23Z")

</div>

@RichieJarvis thanks!

I changed policy as you recommended, now it shows (for example):  
GET nginx-2020.01.13/\_ilm/explain:

```
{
  "indices": {
    "nginx-2020.01.13": {
      "policy": "nginx_index_delete",
      "index": "nginx-2020.01.13",
      "managed": true
    }
  }
}

```

In index summary I see:

 ![Снимок экрана 2020-01-29 в 12.15.58](https://us1.discourse-cdn.com/elastic/original/3X/0/4/04530e41d1ff03a196be8b48cc0dad694faea6e7.png)

that the **Current action time** of Index lifecycle management is `2020-01-29 12:15:50`, but index is not deleted (documentation says that ilm runs every 10 min).

What else could be the problem?

---

<div class="post-metadata">

**Author:** ![SergeSpinoza](https://avatars.discourse-cdn.com/v4/letter/s/c5a1d2/32.png) [@SergeSpinoza](https://discuss.elastic.co/u/SergeSpinoza)\
**Post date:** [January 30, 2020, 10:12am UTC](https://discuss.elastic.co/t/ilm-policy-not-working-for-all-indexes/216792/4 "2020-01-30T10:12:32Z")

</div>

Maybe problem in this?

GET \_ilm/status:

```
{
  "operation_mode": "STOPPED"
}
```

---

<div class="post-metadata">

**Author:** ![SergeSpinoza](https://avatars.discourse-cdn.com/v4/letter/s/c5a1d2/32.png) [@SergeSpinoza](https://discuss.elastic.co/u/SergeSpinoza)\
**Post date:** [January 30, 2020, 10:26am UTC](https://discuss.elastic.co/t/ilm-policy-not-working-for-all-indexes/216792/5 "2020-01-30T10:26:08Z")

</div>

Yes. The problem was in `"operation_mode": "STOPPED"`.

I done `POST _ilm/start` and ILM began to work. Why ILM was self stoped - remains unclear.

---

<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:** [February 27, 2020, 10:26am UTC](https://discuss.elastic.co/t/ilm-policy-not-working-for-all-indexes/216792/6 "2020-02-27T10:26:10Z")

</div>

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