Skip to content

Commit

Permalink
Merge d54199f into backport/gh-13169-show-leader-metrics/formally-ple…
Browse files Browse the repository at this point in the history
…asing-pigeon
  • Loading branch information
hc-github-team-consul-core authored Jun 3, 2022
2 parents 50ac08e + d54199f commit ad744fe
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 @@ -22,6 +22,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 @@ -163,6 +167,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 ad744fe

Please sign in to comment.