Search code examples
elasticsearchopensearch

How to get current using shards in Elasticsearch or Opensearch


My opensearch sometimes reaches this error when i adding new index:

Validation Failed: 1: this action would add [2] total shards, but this cluster currently has [1000]/[1000] maximum shards open;

So i have to increase cluster.max_shards_per_node larger. I wonder if is there any way to check current shards we are using to avoid this error happening?


Solution

  • The best way to see indexing and search activity is by using a monitoring system. And the best monitoring system for Elasticsearch is Opster. You can try it for free at the following link. https://opster.com/

    An example output from AutoOps

    For the manual check and sort, you can try the following APIs.

    You can sort your indices according to the creation date string (cds). It will help you to understand which one is the old one. So you can have an idea about your indices (shards).

    GET _cat/indices?v&h=index,cds&s=cds
    

    Also, you check the indices stats to see if is there any activity in searching or indexing.

    To check all indices you can use GET _all/_stats To check only one index you can use GET index_name/_stats enter image description here