diff --git a/gauges.go b/gauges.go index f73310e..facec33 100644 --- a/gauges.go +++ b/gauges.go @@ -6,6 +6,11 @@ import ( ) var ( + routerUpGauge = promauto.NewGauge(prometheus.GaugeOpts{ + Namespace: nameSpace, + Name: "router_up", + Help: "Tells whether MySQL Router is up", + }) routerStatusGauge = promauto.NewGaugeVec(prometheus.GaugeOpts{ Namespace: nameSpace, Name: "router_status", diff --git a/main.go b/main.go index abce59a..7788b87 100644 --- a/main.go +++ b/main.go @@ -132,8 +132,10 @@ func collectMetrics() { router, err := mysqlRouterClient.GetRouterStatus() if err != nil { writeError(err) + routerUpGauge.Set(float64(0)) return } + routerUpGauge.Set(float64(1)) routerStatusGauge.WithLabelValues(strconv.Itoa(router.ProcessID), router.ProductEdition, router.TimeStarted.String(), router.Version, router.Hostname) // metadata