Skip to content

Commit

Permalink
Merge d54199f into backport/gh-13169-show-leader-metrics/fairly-worth…
Browse files Browse the repository at this point in the history
…y-redbird
  • Loading branch information
hc-github-team-consul-core authored Jun 3, 2022
2 parents d16460a + d54199f commit d5bcdfb
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions agent/consul/session_ttl.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ var SessionGauges = []prometheus.GaugeDefinition{
Name: []string{"raft", "last_index"},
Help: "Represents the raft last index.",
},
{
Name: []string{"raft", "is_leader"},
Help: "Track if the server is a leader.",
},
}

var SessionSummaries = []prometheus.SummaryDefinition{
Expand Down Expand Up @@ -151,6 +155,11 @@ func (s *Server) updateMetrics() {

metrics.SetGauge([]string{"raft", "applied_index"}, float32(s.raft.AppliedIndex()))
metrics.SetGauge([]string{"raft", "last_index"}, float32(s.raft.LastIndex()))
if s.IsLeader() {
metrics.SetGauge([]string{"raft", "is_leader"}, float32(1))
} else {
metrics.SetGauge([]string{"raft", "is_leader"}, float32(0))
}
case <-s.shutdownCh:
return
}
Expand Down

0 comments on commit d5bcdfb

Please sign in to comment.