首先:
感谢博主:参考博客:https://www.orchome.com/477
对于针对性的索引清理定期数据可行方法:
1.手动清理
可基于kibana索引管理进行索引数据清理
2.api清理
curl -XDELETE ‘http://ip:端口/索引‘
3.脚本清理
#!/bin/sh
# example: sh delete_es_by_day.sh logstash-kettle-log logsdate 30
index_name=$1
daycolumn=$2
savedays=$3
format_day=$4
if [ ! -n "$savedays" ]; then
echo "the args is not right,please input again...."
exit 1
fi
if [ ! -n "$format_day" ]; then
format_day=‘%Y%m%d‘
fi
sevendayago=`date -d "-${savedays} day " +${format_day}`
curl -X POST "192.1.80.36:30920/${index_name}/_delete_by_query?pretty" -H "Content-Type: application/json" -d ‘
{
"query": {
"range": {
"‘${daycolumn}‘": {
"from": null,
"to": ‘${sevendayago}‘
}
}
}
}‘
echo "ok"
4.基于脚本定时任务清理数据
将脚本添加到定时任务,定期执行
5.基于elasticsearch-curator定时清理
ElasticSearch定时删除数据(非时间结尾规律索引)
原文:https://www.cnblogs.com/durenniu/p/12365590.html