@@ -48,6 +48,7 @@ var args struct {
48
48
}
49
49
50
50
var (
51
+ lastRouter * mysqlrouter.Router
51
52
lastRoutes []* mysqlrouter.Routes
52
53
lastRouteConnections []* mysqlrouter.RouteConnections
53
54
)
@@ -152,6 +153,8 @@ func collectRouterMetrics() (*mysqlrouter.Router, error) {
152
153
routerUpGauge .Set (1 )
153
154
routerStatusGauge .WithLabelValues (strconv .Itoa (router .ProcessID ), router .ProductEdition , router .TimeStarted .String (), router .Version , router .Hostname )
154
155
156
+ lastRouter = router
157
+
155
158
return router , nil
156
159
}
157
160
@@ -200,10 +203,10 @@ func collectRouteMetrics(router *mysqlrouter.Router) {
200
203
// so route metrics will be 0
201
204
if router == nil {
202
205
for _ , route := range lastRoutes {
203
- routeActiveConnectionsGauge .WithLabelValues (route .Name , router .Hostname ).Set (0 )
204
- routeTotalConnectionsGauge .WithLabelValues (route .Name , router .Hostname ).Set (0 )
205
- routeBlockedHostsGauge .WithLabelValues (route .Name , router .Hostname ).Set (0 )
206
- routeHealthGauge .WithLabelValues (route .Name , router .Hostname ).Set (0 )
206
+ routeActiveConnectionsGauge .WithLabelValues (route .Name , lastRouter .Hostname ).Set (0 )
207
+ routeTotalConnectionsGauge .WithLabelValues (route .Name , lastRouter .Hostname ).Set (0 )
208
+ routeBlockedHostsGauge .WithLabelValues (route .Name , lastRouter .Hostname ).Set (0 )
209
+ routeHealthGauge .WithLabelValues (route .Name , lastRouter .Hostname ).Set (0 )
207
210
208
211
for _ , routeConnection := range lastRouteConnections {
209
212
if args .CollectRouteConnectionsByteFromServer {
0 commit comments