查询索引:
curl -XGET 'http://127.0.0.1:9200/_cat/indices/?v'
二、api删除
[root@elk sh]# curl -XDELETE http://localhost:9200/filebeat-6.0.0-2018.03.07
{"acknowledged":true}
三、脚本加api删除(推荐)
#!/bin/bash#指定日期(2周前)DATA=`date -d "2 weeks ago" +%Y.%m.%d`echo $DATA#当前日期time=`date`#删除2周前的日志curl -XDELETE http://localhost:9200/*-${DATA}if [ $? -eq 0 ];thenecho $time"-->del $DATA log success.." >> /tmp/es-index-clear.logelseecho $time"-->del $DATA log fail.." >> /tmp/es-index-clear.logfi
四、添加到任务计划
crontab -e10 1 * * * sh /data/sh/es-index-clear.sh > /dev/null 2>&1