当然, 可以使用rest接口方式,进行指定index 删除操作, 但是使用自带的 policy , 可以多余的crontab等操作
创建policy 后, 输入下面内容, 大意: 指定index 状态迁移, 并指定相应的 有效时长.
活动时间 15天, 冷数据时间 1天, 然后转入 删除状态(删除数据, 释放磁盘空间)
{
"policy": {
"description": "A simple default policy that changes the replica count between hot and cold states.",
"default_state": "hot",
"states": [
{
"name": "hot",
"actions": [
{
"replica_count": {
"number_of_replicas": 5
}
}
],
"transitions": [
{
"state_name": "cold",
"conditions": {
"min_index_age": "15d"
}
}
]
},
{
"name": "cold",
"actions": [
{
"replica_count": {
"number_of_replicas": 2
}
}
],
"transitions": [
{
"state_name": "delete",
"conditions": {
"min_index_age": "1d"
}
}
]
},
{
"name": "delete",
"actions": [
{
"delete": {}
}
],
"transitions": []
}
],
"ism_template": {
"index_patterns": [
"log-*"
]
}
}
}
网友评论