mathersbe
mathersbe

Reputation: 43

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.

Upvotes: 4

Views: 11870

Answers (2)

Victor Ekpo
Victor Ekpo

Reputation: 41

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

Upvotes: 1

glenacota
glenacota

Reputation: 2547

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

Upvotes: 6

Related Questions