Skip to content

Commit f987bfb

Browse files
author
acabezas
committed
Add router_up gauge
1 parent 84955bf commit f987bfb

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

gauges.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@ import (
66
)
77

88
var (
9+
routerUpGauge = promauto.NewGauge(prometheus.GaugeOpts{
10+
Namespace: nameSpace,
11+
Name: "router_up",
12+
Help: "Tells whether MySQL Router is up",
13+
})
914
routerStatusGauge = promauto.NewGaugeVec(prometheus.GaugeOpts{
1015
Namespace: nameSpace,
1116
Name: "router_status",

main.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,8 +132,10 @@ func collectMetrics() {
132132
router, err := mysqlRouterClient.GetRouterStatus()
133133
if err != nil {
134134
writeError(err)
135+
routerUpGauge.Set(float64(0))
135136
return
136137
}
138+
routerUpGauge.Set(float64(1))
137139
routerStatusGauge.WithLabelValues(strconv.Itoa(router.ProcessID), router.ProductEdition, router.TimeStarted.String(), router.Version, router.Hostname)
138140

139141
// metadata

0 commit comments

Comments
 (0)