ilm_policy_create
Create Index Lifecycle Management policies to automatically manage data through hot, warm, cold, and delete phases based on age and size thresholds.
Instructions
创建 ILM 策略
参数:
policy_id: 策略 ID
hot: 热阶段配置
warm: 温阶段配置
cold: 冷阶段配置
delete: 删除阶段配置
description: 策略描述
示例 - 基本策略:
ilm_policy_create("logs-policy",
hot={
"min_age": "0ms",
"actions": {
"rollover": {"max_size": "50gb", "max_age": "30d"}
}
},
delete={
"min_age": "90d",
"actions": {"delete": {}}
}
)
示例 - 完整生命周期:
ilm_policy_create("full-lifecycle",
hot={
"min_age": "0ms",
"actions": {
"rollover": {"max_size": "50gb", "max_age": "7d"},
"set_priority": {"priority": 100}
}
},
warm={
"min_age": "30d",
"actions": {
"shrink": {"number_of_shards": 1},
"forcemerge": {"max_num_segments": 1},
"set_priority": {"priority": 50}
}
},
cold={
"min_age": "60d",
"actions": {
"set_priority": {"priority": 0}
}
},
delete={
"min_age": "90d",
"actions": {"delete": {}}
}
)
常用 actions:
- rollover: 滚动索引 (max_size, max_age, max_docs)
- shrink: 收缩分片数
- forcemerge: 合并段
- set_priority: 设置恢复优先级
- allocate: 分配到特定节点
- readonly: 设为只读
- delete: 删除索引
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| policy_id | Yes | ||
| hot | No | ||
| warm | No | ||
| cold | No | ||
| delete | No | ||
| description | No |