Skip to content

Instantly share code, notes, and snippets.

@kosztik
Last active September 7, 2020 08:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kosztik/bdafb74cb27af9c9f7b40c3f535d2c68 to your computer and use it in GitHub Desktop.
Save kosztik/bdafb74cb27af9c9f7b40c3f535d2c68 to your computer and use it in GitHub Desktop.
Delete Elasticsearch indexes per month
month="08"
logs=`curl -XGET 'localhost:9200/_cat/indices?v'|grep -oh -E "wazuh-.+\.$month\.[0-9][0-9]"|grep wazuh`
for i in $logs
do
l=`echo $i|grep wazuh`
if ! [ -z "$l" ]
then
echo $l
sleep 3
curl -XDELETE "localhost:9200/$l"
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment