This architecture helps manage data efficiently by storing recent data on fast machines and older data on slower, cheaper machines.
Hot-warm-cold architecture in Elasticsearch
PUT /_ilm/policy/hot-warm-cold-policy
{
"policy": {
"phases": {
"hot": {
"actions": {
"rollover": {
"max_size": "50gb",
"max_age": "30d"
},
"set_priority": { "priority": 100 }
}
},
"warm": {
"min_age": "30d",
"actions": {
"allocate": {
"require": { "data": "warm" }
},
"set_priority": { "priority": 50 }
}
},
"cold": {
"min_age": "90d",
"actions": {
"allocate": {
"require": { "data": "cold" }
},
"set_priority": { "priority": 0 },
"freeze": {}
}
}
}
}
}The policy defines phases: hot, warm, and cold with actions for each.
Use allocate to move data to nodes with matching attributes.
PUT /_ilm/policy/simple-hot-warm
{
"policy": {
"phases": {
"hot": {
"actions": {
"rollover": { "max_age": "7d" },
"set_priority": { "priority": 100 }
}
},
"warm": {
"min_age": "7d",
"actions": {
"allocate": { "require": { "data": "warm" } },
"set_priority": { "priority": 50 }
}
}
}
}
}PUT /_template/logs_template
{
"index_patterns": ["logs-*"],
"settings": {
"index.lifecycle.name": "hot-warm-cold-policy",
"index.lifecycle.rollover_alias": "logs-alias"
}
}This program creates a hot-warm-cold lifecycle policy, sets an index template to use it, and creates the first index with a rollover alias.
PUT /_ilm/policy/hot-warm-cold-policy
{
"policy": {
"phases": {
"hot": {
"actions": {
"rollover": {
"max_size": "50gb",
"max_age": "30d"
},
"set_priority": { "priority": 100 }
}
},
"warm": {
"min_age": "30d",
"actions": {
"allocate": {
"require": { "data": "warm" }
},
"set_priority": { "priority": 50 }
}
},
"cold": {
"min_age": "90d",
"actions": {
"allocate": {
"require": { "data": "cold" }
},
"set_priority": { "priority": 0 },
"freeze": {}
}
}
}
}
}
PUT /_template/logs_template
{
"index_patterns": ["logs-*"],
"settings": {
"index.lifecycle.name": "hot-warm-cold-policy",
"index.lifecycle.rollover_alias": "logs-alias"
}
}
PUT /logs-000001
{
"aliases": {
"logs-alias": {
"is_write_index": true
}
}
}Make sure your Elasticsearch nodes have attributes like node.attr.data: warm or cold to allocate data properly.
Rollover helps create new indices automatically when size or age limits are reached.
Freezing cold indices reduces resource use but makes searches slower.
Hot-warm-cold architecture stores recent data on fast nodes and older data on slower, cheaper nodes.
Use index lifecycle management (ILM) policies to automate data movement between phases.
Rollover and allocation actions help manage data size and location efficiently.