Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ElasticSearch Get Index Names and Store Size

Tags:

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

like image 656
Gregg Avatar asked Apr 21 '15 02:04

Gregg


People also ask

How do I get Elasticsearch index size?

Goto Kibana and then click on "Dev Tools" from Left Menu, Once the console is open run the following command to see size of the given index.

How do I fetch all indexes in Elasticsearch?

You can query localhost:9200/_status and that will give you a list of indices and information about each.

What is store size in Elasticsearch?

store. size is the total index size across the cluster, including replicas, and since you have 1 replica configured, it is twice the size of the primary shard.


1 Answers

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.

like image 174
Olivier Avatar answered Oct 27 '22 07:10

Olivier