Gregg
Gregg

Reputation: 522

ElasticSearch Get Index Names and Store Size

I am attempting to capture a list of all the indexes and their sizes in a way that I could capture the information using Angular's $http service and then iterate through the information using the ng-repeat preferably with something like:

<ul ng-repeat="elsindex in elsIndexHttpResponse"> <li>{{elsindex.name}}:{{elsindex.size}}</li> </ul>

The closest thing I have found is this: http://localhost:9200/_cat/indices?h=index,store.size

Except:

a. its responses are not in json so easily referencing it using the ng-repeat <li> elements isn't going to work; and

b. i would like, if possible, to get the size output to reflect the same unit size (like bytes).

If this involves something complicated then I'd be grateful for pointers on where I should focus.

I am using elasticsearch v1.4.4

Many thanks

Upvotes: 28

Views: 48296

Answers (4)

Binita Bharati
Binita Bharati

Reputation: 5888

In case you want the size of a particular index, the below API works fine on Elastic Search 7.14. curl http://10.29.61.105:9200/employee/_stats where employee is the desired index name.

Upvotes: 1

sonu1986
sonu1986

Reputation: 231

Just a slight modification from above answer.

curl -X GET "localhost:9200/_cat/indices?h=index,store.size&bytes=gb?pretty"

Upvotes: 10

Olivier
Olivier

Reputation: 2681

I realize this question dates already, but wanted to add my 2 cents.

http://localhost:9200/_cat/indices?h=index,store.size&bytes=kb&format=json

Would actually get you exactly what you requested:

  • format=json -> formats the output to json
  • bytes=kb -> outputs the size in kilobytes

Information regarding the size unit was retrieved from cat APIs doc

Possible values for the bytes argument

Information regarding the format was an attempt in Sense, which has some auto-completion features quite useful to detect such options.

Cheers.

Upvotes: 46

Prabin Meitei
Prabin Meitei

Reputation: 2000

Index size in bytes is included with an indices stats API call:

curl http://localhost:9200/_stats/indexing,store

For nicely formatted JSON output, append ?pretty to the end of the URL:

curl http://localhost:9200/_stats/indexing,store?pretty

See the Indices stats API documentation for additional details and related information.

Upvotes: 24

Related Questions