美文网首页
elastic search 自动删除index policy

elastic search 自动删除index policy

作者: 国服最坑开发 | 来源:发表于2021-11-30 15:54 被阅读0次

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

    相关文章

      网友评论

          本文标题:elastic search 自动删除index policy

          本文链接:https://www.haomeiwen.com/subject/ywvknltx.html