Skip to content

Commit

Permalink
Merge d54199f into backport/gh-13169-show-leader-metrics/inherently-w…
Browse files Browse the repository at this point in the history
…ealthy-lab
  • Loading branch information
hc-github-team-consul-core authored Jun 7, 2022
2 parents 946078b + d54199f commit bfc0a7a
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 @@ -24,6 +24,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 @@ -153,6 +157,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 bfc0a7a

Please sign in to comment.