# Listening for ClusterStateEvents and determining Health?

**URL:** <https://discuss.elastic.co/t/listening-for-clusterstateevents-and-determining-health/3775>\
**Category:** Elasticsearch\
**Created:** [January 14, 2011, 1:03am UTC](https://discuss.elastic.co/t/listening-for-clusterstateevents-and-determining-health/3775 "2011-01-14T01:03:33Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Paul\_Smith](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/paul_smith/32/1323_2.png) [@Paul\_Smith](https://discuss.elastic.co/u/Paul_Smith)\
**Post date:** [January 14, 2011, 1:03am UTC](https://discuss.elastic.co/t/listening-for-clusterstateevents-and-determining-health/3775/1 "2011-01-14T01:03:33Z")

</div>

I'm writing a new ES module for exposing some perf data and thought I could  
easily just add a ClusterStateListener and determine from that what the  
'health' of the cluster is, but I can't find the best way to do this because  
the ClusterState object doesn't expose from what I can tell what the health  
is. Plenty of other stuff I can export, but thought the Health value should  
be simple.. ?

i'm sure I'm going blind here.

---

<div class="post-metadata">

**Author:** ![kimchy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kimchy/32/44952_2.png) [@kimchy](https://discuss.elastic.co/u/kimchy)\
**Post date:** [January 15, 2011, 12:13am UTC](https://discuss.elastic.co/t/listening-for-clusterstateevents-and-determining-health/3775/2 "2011-01-15T00:13:37Z")

</div>

Actually, the health calculation is done externally to the cluster state in the actual cluster health action. Might make sense to move it to be computed on the cluster state itself, need to check that it has all it needs there...  
On Friday, January 14, 2011 at 3:03 AM, Paul Smith wrote:

> I'm writing a new ES module for exposing some perf data and thought I could easily just add a ClusterStateListener and determine from that what the 'health' of the cluster is, but I can't find the best way to do this because the ClusterState object doesn't expose from what I can tell what the health is. Plenty of other stuff I can export, but thought the Health value should be simple.. ?
> 
> i'm sure I'm going blind here.

---

<div class="post-metadata">

**Author:** ![Paul\_Smith](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/paul_smith/32/1323_2.png) [@Paul\_Smith](https://discuss.elastic.co/u/Paul_Smith)\
**Post date:** [January 19, 2011, 2:40am UTC](https://discuss.elastic.co/t/listening-for-clusterstateevents-and-determining-health/3775/3 "2011-01-19T02:40:49Z")

</div>

On 15 January 2011 11:13, Shay Banon [shay.banon@elasticsearch.com](mailto:shay.banon@elasticsearch.com) wrote:

> Actually, the health calculation is done externally to the cluster state  
> in the actual cluster health action. Might make sense to move it to be  
> computed on the cluster state itself, need to check that it has all it needs  
> there...

Just as you posted this response I found that Health action (know I  
understand more about how the RESt stuff works, which is also good for me).

I've raised [Issues · elastic/elasticsearch · GitHub](https://github.com/elasticsearch/elasticsearch/issues/#issue/634to)  
track this, it would be nice if that logic could be reworked somewhere  
and exposed when the ClusterState object is created to broadcast to  
listeners.

---

<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:** [July 6, 2017, 4:13am UTC](https://discuss.elastic.co/t/listening-for-clusterstateevents-and-determining-health/3775/4 "2017-07-06T04:13:34Z")

</div>

Closed on July 6, 2017, 4:13am UTC


