惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

WordPress大学
WordPress大学
Microsoft Security Blog
Microsoft Security Blog
Security Archives - TechRepublic
Security Archives - TechRepublic
V
Visual Studio Blog
宝玉的分享
宝玉的分享
IT之家
IT之家
人人都是产品经理
人人都是产品经理
T
The Blog of Author Tim Ferriss
I
InfoQ
B
Blog RSS Feed
T
Threatpost
博客园_首页
M
MIT News - Artificial intelligence
Spread Privacy
Spread Privacy
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
Know Your Adversary
Know Your Adversary
U
Unit 42
Engineering at Meta
Engineering at Meta
C
Cyber Attacks, Cyber Crime and Cyber Security
月光博客
月光博客
Scott Helme
Scott Helme
T
Tor Project blog
有赞技术团队
有赞技术团队
AWS News Blog
AWS News Blog
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
Last Week in AI
Last Week in AI
S
Schneier on Security
Vercel News
Vercel News
博客园 - Franky
C
Cybersecurity and Infrastructure Security Agency CISA
L
LINUX DO - 热门话题
NISL@THU
NISL@THU
L
LangChain Blog
爱范儿
爱范儿
Google DeepMind News
Google DeepMind News
The GitHub Blog
The GitHub Blog
雷峰网
雷峰网
Latest news
Latest news
C
CXSECURITY Database RSS Feed - CXSecurity.com
Hugging Face - Blog
Hugging Face - Blog
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
www.infosecurity-magazine.com
www.infosecurity-magazine.com
G
GRAHAM CLULEY
S
Security Affairs
A
About on SuperTechFans
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
大猫的无限游戏
大猫的无限游戏
W
WeLiveSecurity
Cisco Talos Blog
Cisco Talos Blog
罗磊的独立博客

基础 on 打工人日志

Tmux 安装和使用教程 GNU/Linux 一键更换系统软件源脚本 在windows上安装appium 可观测性和监控的区别 基础知识-计算机系统 systemd 守护命令 Linux crontab 命令 linux常用命令 linux基础知识 yaml 语法 iptables 基础知识 网络基础知识 linux服务基础知识 mysql基础知识 shell基础知识 TCP/IP详解 运维知识图谱
使用 ElasticSearch Curator 7天定期删除日志
2023-11-06 · via 基础 on 打工人日志

使用 ElasticSearch Curator 7天定期删除日志

背景

Curator 是 Elastic 官方发布的一个管理 Elasticsearch 索引的工具,可以完成许多索引生命周期的管理工作。
我使用的 elasticseraech 8.0 以上的版本,所有我直接安装最新版的curator,服务器是centos 7 的

二进制安装

下载

1wget https://packages.elastic.co/curator/5/centos/7/Packages/elasticsearch-curator-5.8.4-1.x86_64.rpm

安装 curator

1rpm -ivh elasticsearch-curator-5.8.4-1.x86_64.rpm
2curator --version

进入安装文件,创建文件

1cd /opt/elasticsearch-curator
2mkdir log
3cd log
4touch run.log

创建config.yml文件在log目录下

config.yml样例如下: 配置说明参考官网说明:config.yml

 1# Rmember, leave a key empty if there is no value.  None will be a string,
 2# not a Python "NoneType"
 3client:
 4  hosts: 
 5    - 192.168.10.17  # elasticsearch IP 地址
 6  port: 9200
 7  url_prefix:
 8  use_ssl: False
 9  certificate:
10  client_cert:
11  client_key:
12  ssl_no_validate: False
13  http_auth: elastic:password # elastic 密码,没有就不用写
14  timeout: 30
15  master_only: False
16
17logging:
18  loglevel: INFO
19  logfile: /opt/elasticsearch-curator/log/run.log
20  logformat: default
21  blacklist: ['elasticsearch', 'urllib3']

创建 elk-7-action.yml 执行 7天自动删除所有日志

aelk-7-action.yml 样例如下: 配置说明参考官网说明:action.yml

 1# Remember, leave a key empty if there is no value.  None will be a string,
 2# not a Python "NoneType"
 3#
 4# Also remember that all examples have 'disable_action' set to True.  If you
 5# want to use this action as a template, be sure to set this to False after
 6# copying it.
 7actions:
 8  1:
 9    action: delete_indices
10    description: >-
11      Delete indices older than 7 days (based on index creation_date)      
12    options:
13      timeout_override:
14      continue_if_exception: False
15      disable_action: False
16    filters:
17    - filtertype: age
18      source: creation_date 
19      direction: older 
20      unit: days
21      unit_count: 7

执行

1curator --config /opt/elasticsearch-curator/log/config.yml /opt/elasticsearch-curator/log/elk-7-action.yml

定时执行

1crontab -e
20 0 * * * curator --config /opt/elasticsearch-curator/log/config.yml /opt/elasticsearch-curator/log/elk-7-action.yml

wq 保存定时任务

总结

curator适用于基于时间或者template其他方式创建的索引,不适合单一索引存储N久历史数据的操作的场景。