Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Delete all indices in elasticsearch

does anyone know where I can find all the data that I imported to elasticsearch through logstash? Where are they stored? I want to delete all indices but cant find them anywhere. When I try to delete them in Kibana, they are still there. I just downloaded zip files from Elasticsearch, Logstash and Kibana and run in directly from the batch file. Did not use any installation.There is a folder data in the elasticsearch folder, i can see the indices , even if I delete them from there, they are still somewhere and taking so much disk space. Any solution for this? Im working on windows 10.

like image 648
mathersbe Avatar asked Sep 16 '25 18:09

mathersbe


2 Answers

In your comment, you clarified that what you are deleting in Kibana is not actual data, but only the index patterns (that's what you have in "Saved Objects") - see Kibana documentation.

If you want to delete data from Kibana, you would need to go to the Dev Tools > Console page (see Kibana documentation | Console), and use the Delete index API to delete your indices. E.g., by running something like

DELETE <your_index>

If you don't know the names of your indices, you can run first the following command in the Dev Tools > Console:

GET _cat/indices
like image 139
glenacota Avatar answered Sep 19 '25 06:09

glenacota


Here is a bash script to delete certain indices programmatically from Opensearch, it is pretty risky to go for the delete all option, that's not recommended.

#!/bin/bash

curl --request GET \
  --url https://<domain>/_cat/indices \
  --<auth headers>
  
cat temp | awk '{print $3}' | grep <filterterm> > list

cat list | while read line; do 
 echo Removing index: $line ..;
 curl --request DELETE \
  --url https://<domain>/$line \
  --<auth headers>
done
like image 35
Victor Ekpo Avatar answered Sep 19 '25 07:09

Victor Ekpo