From 6bcacedda9df5ae5b5f8ca57b00915c1842c1be6 Mon Sep 17 00:00:00 2001 From: Lisandro Pin Date: Sat, 18 Apr 2026 00:15:26 +0200 Subject: [PATCH] Export `master_disconnections` metrics on volume servers. (#9104) This allows to track connection issues and master failovers in real time via Prometheus metrics. Co-authored-by: Lisandro Pin --- weed/server/volume_grpc_client_to_master.go | 2 ++ weed/stats/metrics.go | 9 +++++++++ 2 files changed, 11 insertions(+) diff --git a/weed/server/volume_grpc_client_to_master.go b/weed/server/volume_grpc_client_to_master.go index 6258da9c7..6214711e4 100644 --- a/weed/server/volume_grpc_client_to_master.go +++ b/weed/server/volume_grpc_client_to_master.go @@ -7,6 +7,7 @@ import ( "time" "github.com/seaweedfs/seaweedfs/weed/operation" + "github.com/seaweedfs/seaweedfs/weed/stats" "google.golang.org/grpc" @@ -84,6 +85,7 @@ func (vs *VolumeServer) heartbeat() { time.Sleep(vs.pulsePeriod) } + stats.VolumeServerMasterDisconnections.WithLabelValues(master.String()).Inc() newLeader = "" vs.store.MasterAddress = "" } else { diff --git a/weed/stats/metrics.go b/weed/stats/metrics.go index 4cb53a594..b2c056153 100644 --- a/weed/stats/metrics.go +++ b/weed/stats/metrics.go @@ -362,6 +362,14 @@ var ( Help: "In flight total upload size.", }) + VolumeServerMasterDisconnections = prometheus.NewCounterVec( + prometheus.CounterOpts{ + Namespace: Namespace, + Subsystem: "volumeServer", + Name: "master_disconnections", + Help: "Number of master server disconnections.", + }, []string{"address"}) + S3RequestCounter = prometheus.NewCounterVec( prometheus.CounterOpts{ Namespace: Namespace, @@ -528,6 +536,7 @@ func init() { Gather.MustRegister(VolumeServerConcurrentUploadLimit) Gather.MustRegister(VolumeServerInFlightDownloadSize) Gather.MustRegister(VolumeServerInFlightUploadSize) + Gather.MustRegister(VolumeServerMasterDisconnections) Gather.MustRegister(S3RequestCounter) Gather.MustRegister(S3HandlerCounter)