@@ -170,6 +170,18 @@ var (
170170 prometheus .BuildFQName (namespace , "cluster_health" , "status_is_green" ),
171171 "Whether all primary and replica shards are allocated." ,
172172 []string {"cluster" }, nil )
173+ clusterHealthStatusDesc = prometheus .NewDesc (
174+ prometheus .BuildFQName (namespace , "cluster_health" , "status" ),
175+ "Whether all primary and replica shards are allocated." ,
176+ []string {"cluster" ,"color" }, nil )
177+ clusterHealthStatusIsYellowDesc = prometheus .NewDesc (
178+ prometheus .BuildFQName (namespace , "cluster_health" , "status_is_yellow" ),
179+ "Whether all primary and replica shards are allocated." ,
180+ []string {"cluster" }, nil )
181+ clusterHealthStatusIsRedDesc = prometheus .NewDesc (
182+ prometheus .BuildFQName (namespace , "cluster_health" , "status_is_red" ),
183+ "Whether all primary and replica shards are allocated." ,
184+ []string {"cluster" }, nil )
173185 clusterHealthTimedOutDesc = prometheus .NewDesc (
174186 prometheus .BuildFQName (namespace , "cluster_health" , "timed_out" ),
175187 "XXX WHAT DOES THIS MEAN?" ,
@@ -488,12 +500,29 @@ func (e *Exporter) Collect(ch chan<- prometheus.Metric) {
488500 ch <- prometheus .MustNewConstMetric (clusterHealthRelocatingShardsDesc , prometheus .GaugeValue , float64 (clusterHealth .RelocatingShards ), clusterHealth .ClusterName )
489501 ch <- prometheus .MustNewConstMetric (clusterHealthUnassignedShardsDesc , prometheus .GaugeValue , float64 (clusterHealth .UnassignedShards ), clusterHealth .ClusterName )
490502
503+ healthStatus := 0.0
491504 statusIsGreen := 0.0
492505 if clusterHealth .Status == "green" {
493506 statusIsGreen = 1.0
507+ healthStatus = 0.0
494508 }
495509 ch <- prometheus .MustNewConstMetric (clusterHealthStatusIsGreenDesc , prometheus .GaugeValue , statusIsGreen , clusterHealth .ClusterName )
496510
511+ statusIsYellow := 0.0
512+ if clusterHealth .Status == "yellow" {
513+ statusIsYellow = 1.0
514+ healthStatus = 1.0
515+ }
516+ ch <- prometheus .MustNewConstMetric (clusterHealthStatusIsYellowDesc , prometheus .GaugeValue , statusIsYellow , clusterHealth .ClusterName )
517+
518+ statusIsRed := 0.0
519+ if clusterHealth .Status == "red" {
520+ statusIsRed = 1.0
521+ healthStatus = 2.0
522+ }
523+ ch <- prometheus .MustNewConstMetric (clusterHealthStatusIsRedDesc , prometheus .GaugeValue , statusIsRed , clusterHealth .ClusterName )
524+ ch <- prometheus .MustNewConstMetric (clusterHealthStatusDesc ,prometheus .GaugeValue ,healthStatus ,clusterHealth .ClusterName ,clusterHealth .Status )
525+
497526 timedOut := 0.0
498527 if clusterHealth .TimedOut {
499528 timedOut = 1.0
0 commit comments