• ELK删除30天以前的索引脚本


    脚本形式

    #!/bin/bash
    
    #查询索引
    echo `curl -s -XGET http://172.21.91.64:9200/_cat/indices?v -w '\n'`
    
    #只保留30天内的日志索引(删除30天前一天的日志)
    retain_time=$(date -d "30 days ago" +%Y.%m.%d)
    echo ${retain_time}
    es_api="http://172.21.91.64:9200/*-${retain_time}"
    echo ${es_api}
    
    #删除30天前一天的索引(无密码)
    #curl -XDELETE ${es_api}
    #删除30天前一天的索引(带密码)
    curl --user elastic:a4NDeiXSFTwaUVBSBIJV -XDELETE ${es_api} -w '\n'

    验证:

    curl https://172.21.91.64:9200/*-2021.11.16
    curl -s -XGET http://172.21.91.64:9200/_cat/indices?v    # 查看已经存储的空间

    控制台方式

    PUT _ilm/policy/auditbeat
    {
      "policy" : {
          "phases" : {
            "hot" : {
              "min_age" : "0ms",
              "actions" : {
                "rollover" : {
                  "max_size" : "50gb",
                  "max_age" : "30d"
                }
              }
            },
            "delete": {
                "min_age": "30d",
                "actions": {
                  "delete": {}              
                }
            }
          }
        }
    }

    使劲折腾才会有更好的结果!!!! 如有不对请不吝赐教,感谢! 转载请注明出处!
  • 相关阅读:
    C++中struct和class的区别
    关于LBP特征等价模式的解释
    常用的颜色模型
    flask类装饰器
    flask的方法视图
    flask standrad class 使用
    flask add_url_rule的使用
    模板的继承
    模板变量设置 set 和 with
    模版include的用法
  • 原文地址:https://www.cnblogs.com/huanglingfa/p/15698090.html
Copyright © 2020-2023  润新知