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

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.

{
    "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
`

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

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

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, 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)

1 Like

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