# Monitoring shards number

**URL:** <https://discuss.elastic.co/t/monitoring-shards-number/320621>\
**Category:** Elasticsearch\
**Tags:** elastic-stack-monitoring\
**Created:** [December 6, 2022, 8:17pm UTC](https://discuss.elastic.co/t/monitoring-shards-number/320621 "2022-12-06T20:17:01Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![waitangi](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/waitangi/32/110887_2.png) [@waitangi](https://discuss.elastic.co/u/waitangi)\
**Post date:** [December 6, 2022, 8:17pm UTC](https://discuss.elastic.co/t/monitoring-shards-number/320621/1 "2022-12-06T20:17:01Z")

</div>

Hello  
My customer would like to monitor shards number on Elasticsearch node. He would like to recive email alerting that the limit is about to exceed max value. How to arrange that?  
As far as i know shards number is `index.routing.allocation.total_shards_per_node` value. I can get  
shard number selecting last result from GET \_cat/shards?s=shard.  
Is there anything I'm missing or don't understand or wrong understand?  
I'm rather beginner in administrating ELK, so I just want to make sure that my 'thinking mode' is OK

---

<div class="post-metadata">

**Author:** ![linkerc](https://avatars.discourse-cdn.com/v4/letter/l/13edae/32.png) [@linkerc](https://discuss.elastic.co/u/linkerc)\
**Post date:** [December 6, 2022, 9:21pm UTC](https://discuss.elastic.co/t/monitoring-shards-number/320621/2 "2022-12-06T21:21:33Z")

</div>

shard number is hard set when index is created. So it's not really useful to monitor it since whoever created it knows.  
You can get it by listing all the indices and it'll tell you per index. Or list all the nodes and it'll tell you how many shards are residing on each node.

`index.routing.allocation.total_shards_per_node` is a cluster configuration setting. It's not what you want.

Knowing what your customer really cares about is probably more important.

---

<div class="post-metadata">

**Author:** ![Venkata\_Raja](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/venkata_raja/32/114264_2.png) [@Venkata\_Raja](https://discuss.elastic.co/u/Venkata_Raja)\
**Post date:** [December 7, 2022, 5:17am UTC](https://discuss.elastic.co/t/monitoring-shards-number/320621/3 "2022-12-07T05:17:24Z")

</div>

Hi Waitangi,

You can setup those alerts if you enable stack monitoring, you can also create dashboards like below . All stack monitoring data will be stored in .monitoring-\* data-streams and you can apply threshold rules/watchers on it to trigger email.

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/0/5/0598d04d5d47be6d94f96b3ceec3aa89badb6c0b.png)

---

<div class="post-metadata">

**Author:** ![waitangi](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/waitangi/32/110887_2.png) [@waitangi](https://discuss.elastic.co/u/waitangi)\
**Post date:** [December 8, 2022, 12:52pm UTC](https://discuss.elastic.co/t/monitoring-shards-number/320621/4 "2022-12-08T12:52:18Z")

</div>

Hi Venkata Raja

I don't see any rules related with "Shards number" There is a rule related with "Shared size".  
I don't have any subscriptions / licences. Maybe there is a rule related with "Shard number" that requires additional licence.

---

<div class="post-metadata">

**Author:** ![Venkata\_Raja](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/venkata_raja/32/114264_2.png) [@Venkata\_Raja](https://discuss.elastic.co/u/Venkata_Raja)\
**Post date:** [December 9, 2022, 4:41am UTC](https://discuss.elastic.co/t/monitoring-shards-number/320621/5 "2022-12-09T04:41:40Z")

</div>

Hi Waitangi,

You can leverage Elasticsearch query rule type to achieve that.Here is the sample where i have created rule on cluster total shards.

![image](https://us1.discourse-cdn.com/elastic/original/3X/a/2/a20b70806af2899800c3e34c818efd91e970c9a9.png)

---

<div class="post-metadata">

**Author:** ![waitangi](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/waitangi/32/110887_2.png) [@waitangi](https://discuss.elastic.co/u/waitangi)\
**Post date:** [December 16, 2022, 1:26pm UTC](https://discuss.elastic.co/t/monitoring-shards-number/320621/6 "2022-12-16T13:26:00Z")

</div>

Hi

I'm still trying to monitor shard number in my elastic. Now I have perl script that curl's query "GET /\_cluster/stats?human&pretty" to get total shards that is on my cluster. It's about 1700.  
As I have read the default value for total\_shards\_per\_node is 1000, and that value is not set for my cluster, so the query 'GET /\_cluster/settings?human&pretty' return evary value it has except total\_shards\_per\_node.  
My Elastic cluster has 1 node so number of shards exceed the default value. How coult it be?  
And how can I get the value for maximal shards that can be created.  
All I need is write an email when shard number is about to exceed the specified limit. But what is the limit?  
How the number of shards per cluster refers to number of shards per node and number of shards per index?

---

<div class="post-metadata">

**Author:** ![Venkata\_Raja](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/venkata_raja/32/114264_2.png) [@Venkata\_Raja](https://discuss.elastic.co/u/Venkata_Raja)\
**Post date:** [December 19, 2022, 5:18am UTC](https://discuss.elastic.co/t/monitoring-shards-number/320621/7 "2022-12-19T05:18:31Z")

</div>

Hi,

You will get node shards here,

```auto
GET _nodes/stats?filter_path=nodes.*.indices.shard_stats.total_count

```

Replace \* with node name you have

> All I need is write an email when shard number is about to exceed the specified limit. But what is the limit?

shard limit is 20\* heap\_size

---

<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:** [January 16, 2023, 5:18am UTC](https://discuss.elastic.co/t/monitoring-shards-number/320621/8 "2023-01-16T05:18:46Z")

</div>

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