# What all shards are included in "open shards": (active / unassigned /relocating / initializing) all of them?

**URL:** <https://discuss.elastic.co/t/what-all-shards-are-included-in-open-shards-active-unassigned-relocating-initializing-all-of-them/279754>\
**Category:** Elasticsearch\
**Tags:** elastic-stack-monitoring\
**Created:** [July 27, 2021, 4:54pm UTC](https://discuss.elastic.co/t/what-all-shards-are-included-in-open-shards-active-unassigned-relocating-initializing-all-of-them/279754 "2021-07-27T16:54:51Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Bhavik92](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/bhavik92/32/50344_2.png) [@Bhavik92](https://discuss.elastic.co/u/Bhavik92)\
**Post date:** [July 27, 2021, 4:54pm UTC](https://discuss.elastic.co/t/what-all-shards-are-included-in-open-shards-active-unassigned-relocating-initializing-all-of-them/279754/1 "2021-07-27T16:54:51Z")

</div>

I'm trying to build some monitoring to avoid the errors like this: "  
this cluster currently has [999]/[1000] maximum shards open

Looking at response from cluster\_health I see shards in 4 categories: active / unassigned / relocating / initializing.

To monitor number of open shards as a percentage of maximum shards a cluster can have, do I need to sum all of these 4 categories up ?  
Basically, are these 4 mutually exclusive and factored in while calculating open shards.

```auto
{
    "status": "green",
    "timed_out": false,
    "number_of_nodes": 6,
    "number_of_data_nodes": 3,
    "discovered_master": true,
    "active_primary_shards": 366,
    "active_shards": 1096,
    "relocating_shards": 0,
    "initializing_shards": 0,
    "unassigned_shards": 0,
    "delayed_unassigned_shards": 0,
    "number_of_pending_tasks": 0,
    "number_of_in_flight_fetch": 0,
    "task_max_waiting_in_queue_millis": 0,
    "active_shards_percent_as_number": 100.0
}

```

Another stack overflow question around the same topic: [elasticsearch - How to get number of current open shards in elsticsearch cluster? - Stack Overflow](https://stackoverflow.com/questions/57727309/how-to-get-number-of-current-open-shards-in-elsticsearch-cluster)  
`

---

<div class="post-metadata">

**Author:** ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)\
**Post date:** [July 28, 2021, 8:19am UTC](https://discuss.elastic.co/t/what-all-shards-are-included-in-open-shards-active-unassigned-relocating-initializing-all-of-them/279754/2 "2021-07-28T08:19:31Z")

</div>

Have you seen the last field named `active_shards_percent_as_number`? Would that be helpful already without calculating anything yourself?

---

<div class="post-metadata">

**Author:** ![Bhavik92](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/bhavik92/32/50344_2.png) [@Bhavik92](https://discuss.elastic.co/u/Bhavik92)\
**Post date:** [July 29, 2021, 8:02pm UTC](https://discuss.elastic.co/t/what-all-shards-are-included-in-open-shards-active-unassigned-relocating-initializing-all-of-them/279754/3 "2021-07-29T20:02:23Z")

</div>

> [@Bhavik92](#):
>
> `active_shards_percent_as_number`

Thanks for reply. Ya... but I think that is just the percentage of active shards over all the open shards.  
Looking at answer here: [elasticsearch - unassigned\_shards how to solve it - Stack Overflow](https://stackoverflow.com/questions/40305246/unassigned-shards-how-to-solve-it)

I want to monitor & alarm on the number x in "the cluster has x / y maximum shards open"  
such that it doesn't reach close to y.  
Based on another user's comment on the accepted answer [here](https://stackoverflow.com/questions/57727309/how-to-get-number-of-current-open-shards-in-elsticsearch-cluster), x at least consists of both active as well as unassigned shards. What I'm just not sure of is whether it consists of relocating / initializing shards too. Going by the name of the field, that should be the case but just trying to confirm that.

y is easy to get and I'm getting that by multiplying number of data nodes by max\_shards\_per\_node (gotten from /\_cluster/settings)

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [August 26, 2021, 8:03pm UTC](https://discuss.elastic.co/t/what-all-shards-are-included-in-open-shards-active-unassigned-relocating-initializing-all-of-them/279754/4 "2021-08-26T20:03:16Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
