Skip to content

Commit

Permalink
Collect operator autopilot health metrics
Browse files Browse the repository at this point in the history
Signed-off-by: Charles Zaffery <[email protected]>
  • Loading branch information
chuckyz committed Nov 20, 2020
2 parents 55ca968 + 4a57f65 commit fb2569a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions consul_exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ func (e *Exporter) collectLeaderMetric(ch chan<- prometheus.Metric) bool {
}

func (e *Exporter) collectOperatorAutopilotServerHealthMetric(ch chan<- prometheus.Metric) bool {
if e.operatorHealth == false {
if !e.operatorHealth {
return true
}
clusterHealth, err := e.client.Operator().AutopilotServerHealth(&queryOptions)
Expand All @@ -306,14 +306,14 @@ func (e *Exporter) collectOperatorAutopilotServerHealthMetric(ch chan<- promethe
operatorAutopilotLastTerm, prometheus.CounterValue, float64(server.LastTerm), server.ID, server.Name, server.Address, server.Version,
)
server_health := 0.0
if server.Healthy == true {
if server.Healthy {
server_health = 1.0
}
ch <- prometheus.MustNewConstMetric(
operatorAutopilotHealthy, prometheus.CounterValue, server_health, server.ID, server.Name, server.Address, server.Version,
)
server_voter := 0.0
if server.Voter == true {
if server.Voter {
server_voter = 1.0
}
ch <- prometheus.MustNewConstMetric(
Expand Down
4 changes: 2 additions & 2 deletions consul_exporter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ func TestNewExporter(t *testing.T) {
}

for _, test := range cases {
_, err := NewExporter(consulOpts{uri: test.uri}, "", ".*", true, log.NewNopLogger())
_, err := NewExporter(consulOpts{uri: test.uri}, "", ".*", true, true, log.NewNopLogger())
if test.ok && err != nil {
t.Errorf("expected no error w/ %q, but got %q", test.uri, err)
}
Expand Down Expand Up @@ -208,7 +208,7 @@ consul_service_tag{node="{{ .Node }}",service_id="foobar",tag="tag2"} 1
uri: addr,
timeout: time.Duration(time.Second),
requestLimit: tc.requestLimit,
}, "", "", true, log.NewNopLogger())
}, "", "", true, true, log.NewNopLogger())
if err != nil {
t.Errorf("expected no error but got %q", err)
}
Expand Down

0 comments on commit fb2569a

Please sign in to comment.