elastic search 自動刪除index policy

當然, 可以使用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-*"
            ]
        }
    }
}
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章