ELK之Curator

环境:

window10

elasticsearch 7.16.3

jdk 11

curator-5.8.4

目录

一、介绍

二、配置

 1、创建 curator.yml 

 2、创建 delete_indices.yml

三、运行


需求:想要定时删除几天前es的索引数据

一、介绍

Curator是elasticsearch 官方的一个索引管理工具,可以通过配置文件的方式帮助我们对指定的一批索引进行创建/删除、打开/关闭、快照/恢复等管理操作

二、elasticsearch、curator兼容关系https://www.elastic.co/guide/en/elasticsearch/client/curator/current/version-compatibility.html

二、配置

官方配置示例:https://github.com/elastic/curator/tree/master/examples

 1、创建 curator.yml 

注意:文件中出现中文

修改hosts节点,为自己的es地址

client:
  hosts:
    - localhost
  port: 9200
  url_prefix:
  use_ssl: False
  certificate:
  client_cert:
  client_key:
  ssl_no_validate: False
  http_auth:
  timeout: 30
  master_only: False
 
logging:
  loglevel: INFO
  logfile: 
  logformat: default
  blacklist: ['elasticsearch', 'urllib3']

 2、创建 delete_indices.yml

注意:文件中出现中文

unit_count这里我设置为3天, value匹配filebeat前缀的索引

# Remember, leave a key empty if there is no value.  None will be a string,
# not a Python "NoneType"
#
# Also remember that all examples have 'disable_action' set to True.  If you
# want to use this action as a template, be sure to set this to False after
# copying it.
actions:
  1:
    action: delete_indices
    description: >-
      Delete indices older than 3 days (based on index name), for test-
      prefixed indices. Ignore the error if the filter does not result in an
      actionable list of indices (ignore_empty_list) and exit cleanly.
    options:
      ignore_empty_list: True   
      timeout_override:
      continue_if_exception: True  
      disable_action: False   
    filters:
    - filtertype: kibana  
      exclude: True
    - filtertype: opened   
      exclude: False
    - filtertype: pattern
      kind: prefix
      value: filebeat-
      exclude:
    - filtertype: age
      source: name
      direction: older
      timestring: '%Y.%m.%d'
      unit: days
      unit_count: 3
      exclude: false

 说明:

ignore_empty_list : 如果为True,则在filters空列表时,继续下一个action处理而不是退出程序。
disable_action :action开关,为True表示不执行这个action,默认False
continue_if_exception :发现错误后,继续执行下一个索引操作,默认False
- filtertype: kibana : 是否排除隐藏索引,如.kibana
- filtertype: opened :是否排除open状态的索引
- filtertype: pattern :前缀匹配
- filtertype: age :处理多少天前的索引

三、运行

cmd运行:

curator --config curator.yml delete_indices.yml

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值