Skip to content

Commit 84aa754

Browse files
committed
Ensure that we report up metric when query fails
Previously, we were correctly setting the value for up to 0, but not passing that along. Fixes #6.
1 parent db8498a commit 84aa754

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

elasticsearch_exporter.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,8 @@ func (e *Exporter) Collect(ch chan<- prometheus.Metric) {
234234
vec.Reset()
235235
}
236236

237+
defer func() { ch <- e.up }()
238+
237239
resp, err := e.client.Get(e.URI)
238240
if err != nil {
239241
e.up.Set(0)
@@ -329,7 +331,6 @@ func (e *Exporter) Collect(ch chan<- prometheus.Metric) {
329331
}
330332

331333
// Report metrics.
332-
ch <- e.up
333334

334335
for _, vec := range e.counterVecs {
335336
vec.Collect(ch)

0 commit comments

Comments
 (0)