# Elasticsearch Engineer Lab 7.3: Index lifecycle management query

**URL:** <https://discuss.elastic.co/t/elasticsearch-engineer-lab-7-3-index-lifecycle-management-query/326512>\
**Category:** Elastic Training\
**Created:** [February 26, 2023, 8:12am UTC](https://discuss.elastic.co/t/elasticsearch-engineer-lab-7-3-index-lifecycle-management-query/326512 "2023-02-26T08:12:19Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Bryce\_Fernandes](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/bryce_fernandes/32/71166_2.png) [@Bryce\_Fernandes](https://discuss.elastic.co/u/Bryce_Fernandes)\
**Post date:** [February 26, 2023, 8:12am UTC](https://discuss.elastic.co/t/elasticsearch-engineer-lab-7-3-index-lifecycle-management-query/326512/1 "2023-02-26T08:12:19Z")

</div>

Course: Elasticsearch Engineer Lab 7.3: Index lifecycle management  
Version: 8.1  
Question: Query regarding rollover duration

Below is the lab question:

- the index is in the hot phase for 2 minutes
- when the index rolls over, it immediately moves to the warm phase, and the number of replicas is set to 1
- after 2 minutes in the warm phase, the index moves to the cold phase and the number of replicas is set to 0
- 5 minutes after rolling over, the index is deleted

Solution provided:

```auto
PUT _ilm/policy/my-metrics-policy
{
  "policy": {
    "phases": {
      "hot": {
        "actions": {
          "rollover": {
            "max_age": "2m"
          },
          "set_priority": {
            "priority": 100
          }
        },
        "min_age": "0ms"
      },
      "warm": {
        "min_age": "0d",
        "actions": {
          "set_priority": {
            "priority": 50
          },
          "allocate": {
            "number_of_replicas": 1
          }
        }
      },
      "cold": {
        "min_age": "2m",
        "actions": {
          "set_priority": {
            "priority": 0
          },
          "allocate": {
            "number_of_replicas": 0
          }
        }
      },
      "delete": {
        "min_age": "5m",
        "actions": {
          "delete": {}
        }
      }
    }
  }
}

```

I assume the solution to work as below:

- the index is in the hot phase for 2 minutes
- when the index rolls over, it immediately moves to the warm phase, and the number of replicas is set to 1
- after **"0"** minutes in the warm phase or **2 mins from rollover** , the index moves to the cold phase and the number of replicas is set to 0
- 5 minutes after rolling over, the index is deleted

For index to be in warm phase for 2 mins and then rollover, I assume min\_age should be 4m in cold phase.

```auto
      "cold": {
        "min_age": "4m",
        "actions": {
          "set_priority": {
            "priority": 0
          }

```

Correct me if I am wrong. 🙂

Thanks,  
Bryce

---

<div class="post-metadata">

**Author:** ![Bryce\_Fernandes](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/bryce_fernandes/32/71166_2.png) [@Bryce\_Fernandes](https://discuss.elastic.co/u/Bryce_Fernandes)\
**Post date:** [February 27, 2023, 12:12pm UTC](https://discuss.elastic.co/t/elasticsearch-engineer-lab-7-3-index-lifecycle-management-query/326512/2 "2023-02-27T12:12:51Z")

</div>

Apologies, cleared the confusion between rollover time and moving to phase time.  
Solution provided in the lab is correct.

Regards,  
Bryce

---

<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 29, 2023, 12:13pm UTC](https://discuss.elastic.co/t/elasticsearch-engineer-lab-7-3-index-lifecycle-management-query/326512/3 "2023-03-29T12:13:36Z")

</div>

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