I would like to list all indexes present on an ElasticSearch server. I tried this:
curl -XGET localhost:9200/
but it just gives me this:
I use the _stats/indexes
endpoint to get a json blob of data and then filter with jq.
curl 'localhost:9200/_stats/indexes' | jq '.indices | keys | .[]'
"admin"
"blazeds"
"cgi-bin"
"contacts_v1"
"flex2gateway"
"formmail"
"formmail.pl"
"gw"
...
If you don't want quotes, add a -r
flag to jq.
Yes, the endpoint is indexes
and the data key is indices
, so they couldn't make up their minds either :)
I needed this to clean up these garbage indices created by an internal security scan (nessus).
PS. I highly recommend getting familiar with jq if you're going to interact with ES from the command line.