Jason Leidigh
Jason Leidigh

Reputation: 555

Elasticsearch GET API for Shard Size

With Elasticsearch 2.3.3, is there a way to get shard sizes using the GET API which returns JSON?

Currently I have found the following methods to get shard size, both of which are problematic:

  1. /_recovery -> Responds with JSON and provides shard size BUT replica shards are reported as having "size_in_bytes" as 0 which is incorrect.

  2. /_cat/shards -> Provides the correct/desired info BUT is NOT JSON and sizes are reported in non uniform units as strings (ex. 3.2KB, 4.9MB etc.). This endpoint is more for visual consumption whereas I want to consume the response programmatically from an AJAX call.

I've done a lot of searching on Google / Elastic.com but have not found anything, but I would be very surprised if it is not available....

Any ideas? Thanks!!

Upvotes: 7

Views: 11595

Answers (2)

Pavlo Chechehov
Pavlo Chechehov

Reputation: 432

Another way to get shards size is by the request:

curl -XGET localhost:9200/_cat/shards?v=true&format=JSON&bytes=b (mb, gb and etc.)

This is more convenient and better way to get information about shards, specially about size.

Elastic documentation: elastic doc

Upvotes: 4

pickypg
pickypg

Reputation: 22332

Animesh was right, the _stats API is the one that you want, but to get shard level stats, you must specify the level parameter:

curl -XGET host:9200/my-index/_stats?level=shards

The level can currently be set to any of:

  • shards
  • index (default)
  • node

Upvotes: 9

Related Questions