Reputation: 555
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:
/_recovery
-> Responds with JSON and provides shard size BUT replica shards are reported as having "size_in_bytes" as 0 which is incorrect.
/_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
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
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:
Upvotes: 9