Lesson 5 of 9 · 24m
Retention Economics and Index Lifecycle Management
Hot, warm, cold, frozen, and delete — how to put a dollar sign on log retention and implement ILM without guessing.
Log retention is not a compliance slide. It is a multiplication problem: bytes per event times events per second times seconds retained, plus replicas, plus indexing overhead. Teams are shocked by the bill because nobody wrote that equation down before turning on debug logging in production.
Do the arithmetic
Example: 8,000 events/sec * 86,400 sec/day * 2.5 KB = 1.73 TB/day. Thirty days primary plus replica is roughly 103 TB before snapshots.
The ingestion rate did not look scary in a meeting. The retention graph does.
Elastic ILM is a lifecycle, not a delete cron
A practical policy:
PUT _ilm/policy/logs-app-policy
{
"policy": {
"phases": {
"hot": {
"actions": {
"rollover": {"max_primary_shard_size": "30gb", "max_age": "1d"}
}
},
"warm": {
"min_age": "2d",
"actions": {
"shrink": {"number_of_shards": 1},
"forcemerge": {"max_num_segments": 1},
"allocate": {"require": {"data": "warm"}}
}
},
"cold": {
"min_age": "14d",
"actions": {"allocate": {"require": {"data": "cold"}}}
},
"delete": {"min_age": "30d"}
}
}
}Rollover by size and age. Shrink when write pressure is gone. Delete when the business can actually tolerate deletion — not when the storage graph looks ugly.
Retention is a product decision
Security teams may need authentication logs for a year; product teams may need seven days of verbose API logs; kernel audit noise might deserve forty-eight hours. Use different streams and policies: verbose logs short-lived, security events long-lived and restricted, sampled diagnostics cheap and durable, full-fidelity archives in object storage for restore on demand.
Loki changes the cost shape
Loki indexes labels instead of message bodies, so storage is cheaper but label design becomes critical. Low cost is not an excuse to keep everything forever; queries over months of junk are still operationally expensive.
Field notes
- Measure stored size, not raw input size. Indexing, replicas, and doc values are real bytes.
- Snapshots are backups, not retention tiers. Do not confuse restore capability with searchable retention.
- Test deletion. Many teams discover ILM was not attached to the template only after disks fill.
- Legal/compliance retention beats convenience. Ask before deleting security telemetry.
Was this lesson helpful?