当查看elasticsearch-head发现收集了一些比较老旧的日志,可以通过如下方式进行清理
1.手动删除
输入如下命令,返回{"acknowledged":true}表示对应日志已删除。
curl -XDELETE "http://192.168.170.20:9200/windowslog-2022.02"
2.定时删除
cd /home
vim remove_old.sh
#!/bin/bash
SevenMonth=`date -d "7 months ago" +%Y.%m`
curl -XDELETE "http://192.168.170.20:9200/windowslog-$SevenMonth"
chmod u+x remove_old.sh
crontab -e
1 0 * * * /home/remove_old.sh
3.在Kibana页面批量删除
删除后查看elasticsearch-head发现对应索引自动删除