當然, 可以使用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-*"
]
}
}
}