Index lifecycle management helps you automatically manage your data as it grows old or becomes less important. It saves space and keeps your search fast.
Index lifecycle management in Elasticsearch
PUT _ilm/policy/<policy_name>
{
"policy": {
"phases": {
"hot": {
"actions": {
"rollover": {
"max_size": "50gb",
"max_age": "30d"
}
}
},
"delete": {
"min_age": "90d",
"actions": {
"delete": {}
}
}
}
}
}The policy defines phases like hot, warm, cold, and delete.
Each phase has actions like rollover, shrink, or delete to manage indexes automatically.
PUT _ilm/policy/log_policy
{
"policy": {
"phases": {
"hot": {
"actions": {
"rollover": {
"max_age": "7d"
}
}
},
"delete": {
"min_age": "30d",
"actions": {
"delete": {}
}
}
}
}
}PUT _ilm/policy/archive_policy
{
"policy": {
"phases": {
"warm": {
"min_age": "30d",
"actions": {
"allocate": {
"require": {
"box_type": "warm"
}
}
}
},
"cold": {
"min_age": "60d",
"actions": {
"freeze": {}
}
}
}
}
}This example creates a policy that rolls over indexes daily or after 10GB and deletes them after 7 days. Then it retrieves the policy to confirm.
PUT _ilm/policy/sample_policy
{
"policy": {
"phases": {
"hot": {
"actions": {
"rollover": {
"max_size": "10gb",
"max_age": "1d"
}
}
},
"delete": {
"min_age": "7d",
"actions": {
"delete": {}
}
}
}
}
}
GET _ilm/policy/sample_policyMake sure your index template uses the lifecycle policy by setting index.lifecycle.name.
Rollover requires a write alias to work properly.
Phases run automatically based on index age and size.
Index lifecycle management automates index handling to save space and improve performance.
Policies define phases with actions like rollover and delete.
Use ILM to reduce manual work and keep your Elasticsearch cluster healthy.
Practice
Solution
Step 1: Understand ILM's role
ILM automates managing indexes through their lifecycle phases.Step 2: Identify the benefit
Automation helps save space and improves cluster health and performance.Final Answer:
To automate index handling and improve cluster performance -> Option AQuick Check:
ILM automates index management = A [OK]
- Thinking ILM is for manual index creation
- Confusing ILM with backup or encryption
- Assuming ILM only deletes indexes
Solution
Step 1: Check rollover action syntax
Rollover requires conditions like max_size and max_age in a JSON object.Step 2: Validate options
"rollover": { "max_size": "50gb", "max_age": "30d" } correctly uses max_size and max_age keys with proper values.Final Answer:
"rollover": { "max_size": "50gb", "max_age": "30d" } -> Option AQuick Check:
Rollover needs max_size and max_age keys = A [OK]
- Using string 'true' instead of object for rollover
- Missing max_age or max_size keys
- Using incorrect key names like 'size'
{"phases": {"hot": {"actions": {"rollover": {"max_size": "10gb"}}}, "delete": {"min_age": "90d", "actions": {"delete": {}}}}}What happens to an index after it reaches 10GB?
Solution
Step 1: Analyze rollover action in hot phase
The policy rolls over the index when it reaches 10GB.Step 2: Understand delete phase timing
Deletion happens only after 90 days, so not immediate.Final Answer:
It rolls over to a new index and continues indexing -> Option BQuick Check:
Rollover at 10GB, delete after 90d = D [OK]
- Confusing rollover with immediate deletion
- Ignoring min_age delay for delete phase
- Assuming data stops indexing after rollover
{"phases": {"hot": {"actions": {"rollover": {"max_size": "20gb"}}}, "warm": {"min_age": "10d", "actions": {"shrink": {"number_of_shards": 1}}}}}After applying, the shrink action never runs. What is the likely cause?
Solution
Step 1: Check warm phase min_age
Shrink runs only after index is at least 10 days old.Step 2: Confirm index age
If index age is less than 10 days, shrink won't trigger yet.Final Answer:
The index has not reached 10 days old yet -> Option DQuick Check:
min_age controls action timing = C [OK]
- Assuming shrink needs delete phase
- Changing rollover size unrelated to shrink
- Placing shrink in wrong phase
- Rolls over an index at 30GB or 15 days
- Moves the index to warm phase after rollover
- Deletes the index 60 days after rollover
Which policy configuration correctly implements this?
Solution
Step 1: Verify rollover conditions
{"phases": {"hot": {"actions": {"rollover": {"max_size": "30gb", "max_age": "15d"}}}, "warm": {"min_age": "15d", "actions": {}}, "delete": {"min_age": "60d", "actions": {"delete": {}}}}} uses max_size 30gb and max_age 15d, matching requirements.Step 2: Check warm and delete phases
Warm phase starts at 15d (after rollover), delete at 60d, as required.Step 3: Confirm other options
Other options have wrong sizes, ages, or missing actions.Final Answer:
{"phases": {"hot": {"actions": {"rollover": {"max_size": "30gb", "max_age": "15d"}}}, "warm": {"min_age": "15d", "actions": {}}, "delete": {"min_age": "60d", "actions": {"delete": {}}}}} -> Option CQuick Check:
Rollover at 30gb/15d, warm at 15d, delete at 60d = B [OK]
- Swapping max_size and max_age values
- Setting warm min_age too late
- Missing delete action or wrong min_age
Ready to prove it?
Pass the test and this pattern moves unknown
