Browse Source

metrics master is leader

pull/2613/head
Konstantin Lebedev 3 years ago
parent
commit
c9952759c4
  1. 3
      weed/server/master_grpc_server.go
  2. 13
      weed/stats/metrics.go

3
weed/server/master_grpc_server.go

@ -237,7 +237,10 @@ func (ms *MasterServer) KeepConnected(stream master_pb.Seaweed_KeepConnectedServ
} }
case <-ticker.C: case <-ticker.C:
if !ms.Topo.IsLeader() { if !ms.Topo.IsLeader() {
stats.MasterRaftIsleader.Set(0)
return ms.informNewLeader(stream) return ms.informNewLeader(stream)
} else {
stats.MasterRaftIsleader.Set(1)
} }
case <-stopChan: case <-stopChan:
return nil return nil

13
weed/stats/metrics.go

@ -28,6 +28,14 @@ var (
Help: "Counter of master client leader updates.", Help: "Counter of master client leader updates.",
}, []string{"type"}) }, []string{"type"})
MasterRaftIsleader = prometheus.NewGauge(
prometheus.GaugeOpts{
Namespace: "SeaweedFS",
Subsystem: "master",
Name: "is leader",
Help: "is leader",
})
MasterReceivedHeartbeatCounter = prometheus.NewCounterVec( MasterReceivedHeartbeatCounter = prometheus.NewCounterVec(
prometheus.CounterOpts{ prometheus.CounterOpts{
Namespace: "SeaweedFS", Namespace: "SeaweedFS",
@ -153,6 +161,11 @@ var (
) )
func init() { func init() {
Gather.MustRegister(MasterClientConnectCounter)
Gather.MustRegister(MasterRaftIsleader)
Gather.MustRegister(MasterReceivedHeartbeatCounter)
Gather.MustRegister(MasterLeaderChangeCounter)
Gather.MustRegister(FilerRequestCounter) Gather.MustRegister(FilerRequestCounter)
Gather.MustRegister(FilerRequestHistogram) Gather.MustRegister(FilerRequestHistogram)
Gather.MustRegister(FilerStoreCounter) Gather.MustRegister(FilerStoreCounter)

Loading…
Cancel
Save