Don't count empty collection as success (#1613)

Many collectors depend on underlying features to be enabled. This causes
confusion about what "success" means. This changes the behavior of the
`node_scrape_collector_success` metric.

* When a collector is unable to find data don't return success.
* Catch the no data error and send to Debug log level to avoid log spam.
* Update collectors to support this new functionality.
* Fix copy-pasta mistake in infiband debug message.

Closes: https://github.com/prometheus/node_exporter/issues/1323

Signed-off-by: Ben Kochie <superq@gmail.com>
This commit is contained in:
Ben Kochie 2020-02-19 16:11:29 +01:00 committed by GitHub
commit 3e1b0f1bee
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 26 additions and 12 deletions

View file

@ -167,11 +167,11 @@ func (c *wifiCollector) Update(ch chan<- prometheus.Metric) error {
// Cannot access wifi metrics, report no error.
if os.IsNotExist(err) {
level.Debug(c.logger).Log("msg", "wifi collector metrics are not available for this system")
return nil
return ErrNoData
}
if os.IsPermission(err) {
level.Debug(c.logger).Log("msg", "wifi collector got permission denied when accessing metrics")
return nil
return ErrNoData
}
return fmt.Errorf("failed to access wifi data: %w", err)