Removing old indices in elasticsearch

后端 未结 9 2114
生来不讨喜
生来不讨喜 2020-12-07 21:12

I have the many of my logs indexed in logstash-Year-Week format. That is if i want to delete indices older than a few weeks, how can I achieve that in elasticsearch. Is ther

9条回答
  •  暖寄归人
    2020-12-07 21:31

    you can use curl

     curl -X DELETE http://localhost:9200/filebeat-$(date +"%Y.%m.%d" -d "last Month")
    

    this must to add this command to xxx.sh, and you can create crontab. crontab -e

    00 00 * * * /etc/elasticsearch/xxx.sh
    

    this cron will running everyday at 12pm and it will remove old log.

提交回复
热议问题