Automating Index Lifecycle Management in Elasticsearch: A Production‑Ready Design
Discover a minimal yet powerful Elasticsearch ILM policy that automates hot‑warm‑cold tiering, cost control, and data retention, complete with operational checks and safeguards for production clusters.
31 Mar 2026, 16:42 UTC

Problem Statement
In a production Elasticsearch cluster, data arrives continuously and must be kept searchable while keeping storage costs in check. Manually moving indices between tiers or deleting stale data is error‑prone and scales poorly. Index Lifecycle Management (ILM) automates the migration of shards through hot, warm, cold, and delete phases, aligning data freshness with performance and cost requirements.
Requirements
- Cluster version 7.10+ (ILM introduced in 7.10; best supported in 8.x).
- At least two data tiers: hot (for recent writes) and cold (for archival). Optional warm tier for intermediate performance.
- Shard allocation awareness configured so that ILM actions do not overload a single tier.
- Snapshot lifecycle or searchable snapshots enabled if cold indices are to be archived.
Minimal ILM Design
The simplest policy that satisfies most production scenarios is a three‑phase ILM policy: hot → warm → delete. If a warm tier is not required, the warm phase can be omitted and indices move directly from hot to cold.
PUT /_ilm/policy/my_policy
{
"policy": {
"phases": {
"hot": {
"actions": {
"rollover": {
"max_age": "30d",
"max_size": "50gb"
}
}
},
"warm": {
"min_age": "30d",
"actions": {
"allocate": {
"require": {
"tier": "warm"
}
},
"set_priority": {"priority": 50}
}
},
"delete": {
"min_age": "90d",
"actions": {
"delete": {}
}
}
}
}
}
Key points:
- The hot phase rolls over after 30 days or 50 GB, moving the index to a new name and creating a fresh hot index.
- The warm phase allocates shards to nodes tagged with
tier: warmand lowers priority to reduce impact on hot‑tier latency. - The delete phase removes indices older than 90 days, freeing storage.
Apply this policy to all indices that share the same retention strategy via an index template:
PUT /_template/my_template
{
"index_patterns": ["app-logs-*"],
"settings": {
"index.lifecycle.name": "my_policy",
"index.lifecycle.rollover_alias": "app-logs"
}
}
Trust and Data Boundaries
ILM actions are performed by the elasticsearch user, which must have cluster:admin:ilm:* and indices:admin:ilm:* privileges. Restrict policy modifications to a dedicated operator role to prevent accidental data loss. Use _ilm/explain to verify that the policy applies only to intended indices.
Operational Checks
- Policy Verification
RunGET /_ilm/policy/my_policyto confirm the JSON matches the desired configuration. Expect a 200 response with the policy body. - Index Phase Confirmation
For any index:GET /app-logs-2026.10.16/_ilm/explain. The response containsphase,action, andstepfields. Verify that the index is in the expected phase and that the next scheduled action aligns with the policy. - Cluster Health Monitoring
During a phase transition, watchcluster.routing.allocation.cluster_info.total_shardsandcluster.routing.allocation.cluster_info.total_in_flight_movesvia the Cluster Health API. A spike in in‑flight moves can signal rebalancing pressure. - Performance Metrics
Track search latency (e.g.,search.query_time_in_millis) before and after a hot‑to‑warm migration. If latency rises >10%, investigate shard placement or tier capacity. - Snapshot Integration
If using searchable snapshots, schedule a snapshot lifecycle policy that triggers when an index enters the cold phase. Verify viaGET /_snapshot/_statusthat snapshots complete successfully.
Failure Modes and Design‑Change Triggers
- Rebalancing Overload
If the warm tier is saturated, ILM moves may trigger cluster rebalancing, causing latency spikes. Action: add more warm nodes or adjust themin_ageto delay the move. - Unintended Data Retention
A misconfiguredmax_ageormax_sizecan keep indices in the hot phase longer than intended, inflating storage costs. Action: audit policies in staging before promotion. - Delete Before Snapshot
If a delete phase runs before a snapshot completes, data may be lost. Ensure snapshot lifecycle runs earlier than the delete phase or use searchable snapshots that keep data in S3. - Cluster Capacity Exhaustion
When the cold tier reaches capacity, ILM may attempt to allocate new shards to the hot tier, causing a cascade of migrations. Action: monitorcluster.routing.allocation.total_shardsand provision additional storage or archive indices. - Policy Drift
Manual changes to index settings can bypass ILM. Enforceindex.lifecycle.namevia templates and disable manual rollovers withindex.lifecycle.rollover_aliasset tonone.
When any of these conditions manifest, revisit the ILM policy: adjust phase durations, add or remove tiers, or integrate with additional lifecycle management tools. Regularly run the GET /_ilm/explain API to ensure indices remain on the intended path.
Conclusion
By defining a single, well‑tested ILM policy and applying it through a template, production clusters can automate tiering, retention, and cost control with minimal operational overhead. Continuous monitoring of phase transitions and cluster health ensures that the system remains resilient and that data is neither prematurely deleted nor unnecessarily retained.
0 replies
A thoughtful contribution can make all the difference. Be the first to share one.