elasticsearch delete index older than

bash script rotate-elasticsearch-index.sh
should to change regDate=”$yearReg\\-$monthReg\\-$dayReg” to match your index date format

curl -X PUT “localhost:9200/test_2022-08-02-test?pretty”
{
“acknowledged” : true,
“shards_acknowledged” : true,
“index” : “test_2022-08-02-test”
}

./rotate-elasticsearch-index.sh test localhost:9200 1
=== Fri Aug 12 16:35:37 EEST 2022 ===
——————————————-
INFO: Index: test_2022-08-11-110602
INFO: Found date: 2022-08-11
INFO: test_2022-08-11-110602 is less than 1 days old, doing nothing.
——————————————-
INFO: Index: test_2022-08-12-110602
INFO: Found date: 2022-08-12
INFO: testas_2022-08-12-110602 is less than 1 days old, doing nothing.
——————————————-
INFO: Index: test_2022-08-02-test
INFO: Found date: 2022-08-02
DELETE: test_2022-08-02-test is about to be deleted.

Leave a Reply

Your email address will not be published.