@@ -200,6 +200,18 @@ var (
200
200
prometheus .BuildFQName (namespace , "cluster_health" , "status_is_green" ),
201
201
"Whether all primary and replica shards are allocated." ,
202
202
[]string {"cluster" }, nil )
203
+ clusterHealthStatusDesc = prometheus .NewDesc (
204
+ prometheus .BuildFQName (namespace , "cluster_health" , "status" ),
205
+ "Whether all primary and replica shards are allocated." ,
206
+ []string {"cluster" , "color" }, nil )
207
+ clusterHealthStatusIsYellowDesc = prometheus .NewDesc (
208
+ prometheus .BuildFQName (namespace , "cluster_health" , "status_is_yellow" ),
209
+ "Whether all primary and replica shards are allocated." ,
210
+ []string {"cluster" }, nil )
211
+ clusterHealthStatusIsRedDesc = prometheus .NewDesc (
212
+ prometheus .BuildFQName (namespace , "cluster_health" , "status_is_red" ),
213
+ "Whether all primary and replica shards are allocated." ,
214
+ []string {"cluster" }, nil )
203
215
clusterHealthTimedOutDesc = prometheus .NewDesc (
204
216
prometheus .BuildFQName (namespace , "cluster_health" , "timed_out" ),
205
217
"XXX WHAT DOES THIS MEAN?" ,
@@ -552,11 +564,22 @@ func (e *Exporter) Collect(ch chan<- prometheus.Metric) {
552
564
ch <- prometheus .MustNewConstMetric (clusterHealthRelocatingShardsDesc , prometheus .GaugeValue , float64 (clusterHealth .RelocatingShards ), clusterHealth .ClusterName )
553
565
ch <- prometheus .MustNewConstMetric (clusterHealthUnassignedShardsDesc , prometheus .GaugeValue , float64 (clusterHealth .UnassignedShards ), clusterHealth .ClusterName )
554
566
555
- statusIsGreen := 0.0
556
- if clusterHealth .Status == "green" {
567
+ var statusIsGreen , statusIsYellow , statusIsRed , healthStatus float64
568
+ switch clusterHealth .Status {
569
+ case "green" :
557
570
statusIsGreen = 1.0
571
+ healthStatus = 0.0
572
+ case "yellow" :
573
+ statusIsYellow = 1.0
574
+ healthStatus = 1.0
575
+ case "red" :
576
+ statusIsRed = 1.0
577
+ healthStatus = 2.0
558
578
}
559
579
ch <- prometheus .MustNewConstMetric (clusterHealthStatusIsGreenDesc , prometheus .GaugeValue , statusIsGreen , clusterHealth .ClusterName )
580
+ ch <- prometheus .MustNewConstMetric (clusterHealthStatusIsYellowDesc , prometheus .GaugeValue , statusIsYellow , clusterHealth .ClusterName )
581
+ ch <- prometheus .MustNewConstMetric (clusterHealthStatusIsRedDesc , prometheus .GaugeValue , statusIsRed , clusterHealth .ClusterName )
582
+ ch <- prometheus .MustNewConstMetric (clusterHealthStatusDesc , prometheus .GaugeValue , healthStatus , clusterHealth .ClusterName , clusterHealth .Status )
560
583
561
584
timedOut := 0.0
562
585
if clusterHealth .TimedOut {
0 commit comments