ICode9

精准搜索请尝试: 精确搜索
首页 > 其他分享> 文章详细

elasticsearch-curator使用

2021-11-16 10:32:05  阅读:207  来源: 互联网

标签:False name filtertype curator action elasticsearch 使用 indices


elasticsearch-curator解决什么问题

自动化清理es索引

版本对应的es

https://www.elastic.co/guide/en/elasticsearch/client/curator/current/version-compatibility.html在这里插入图片描述

安装

pip3 install elasticsearch-curator

使用

#获取所有索引
curator_cli --host 10.33.4.160 --port 9200 show_indices --verbos


#configuration配置文件
---
# Remember, leave a key empty if there is no value.  None will be a string,
# not a Python "NoneType"
client:
  hosts:
    - 10.33.4.160
  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: /var/log/curator.log
  logformat: default
  blacklist: ['elasticsearch', 'urllib3']
  
#定时任务
0 14 * * * curator --config ~/.curator/curator.yml ~/.curator/action.yml & >/dev/null 2>&1

client:
  hosts:
    - 172.16.0.137
  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: /export/logs/curator.log
  logformat: default
  blacklist: ['elasticsearch', 'urllib3']

actions:
  7:
    action: delete_indices
    description: "Delete indices older than 180 days (based on index name), for logstash- prefixed indices."
    options:
      timeout_override:
      continue_if_exception: False
      disable_action: False
    filters:
    - filtertype: pattern
      kind: prefix
      value: hdgg_nginx_access-
    - filtertype: age
      source: name
      direction: older
      unit: days
      unit_count: 90
      timestring: '%Y.%m.%d'


  14:
    action: delete_indices
    description: >-
      Close indices older than 30 days (based on index name), for syslog-
      prefixed indices.
    options:
      timeout_override:
      continue_if_exception: False
      disable_action: False
    filters:
    - filtertype: pattern
      kind: prefix
      value: cdn-log-
    - filtertype: age
      source: name
      direction: older
      timestring: '%Y.%m.%d'
      unit: days
      unit_count: 180
      

actions:
  1:
    action: close
    description: >-
      Close indices older than 30 days (based on index name), for syslog-
      prefixed indices.
    options:
      ignore_empty_list: True
      delete_aliases: False
#      disable_action: True
    filters:
    - filtertype: pattern
      kind: prefix
      value: auditlog-
    - filtertype: age
      source: name
      direction: older
      timestring: '%Y-%m-%d'
      unit: days
      unit_count: 15


  22:
    action: delete_indices
    description: "Delete indices older than 30 days (based on index name), for adx-stat- prefixed indices."
    options:
      timeout_override:
      continue_if_exception: False
      disable_action: False
    filters:
    - filtertype: pattern
      kind: prefix
      value: adx-stat-
    - filtertype: age
      source: name
      direction: older
      unit: days
      unit_count: 15
      timestring: '%Y.%m.%d'
      
#一次性执行

很直观的配置,每个参数的含义都很清楚。这里需要指出的是,如果不配置参数的话,留空,即可,不要画蛇添足的写None。

另外,logfile如果不填的话,默认是输出到stdout。推荐是存储到文件中。如上例。

标签:False,name,filtertype,curator,action,elasticsearch,使用,indices
来源: https://blog.csdn.net/m0_37845900/article/details/121349964

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有