Fix rapl collector log noise

Capture permission denied error for "energy_uj" file.

Fixes: https://github.com/prometheus/node_exporter/issues/1892

Signed-off-by: Ben Kochie <superq@gmail.com>
This commit is contained in:
Ben Kochie 2021-07-21 19:28:54 +02:00
parent 5bee84f30d
commit 502f287c96
No known key found for this signature in database
GPG Key ID: C646B23C9E3245F1
1 changed files with 4 additions and 0 deletions

View File

@ -70,6 +70,10 @@ func (c *raplCollector) Update(ch chan<- prometheus.Metric) error {
for _, rz := range zones { for _, rz := range zones {
newMicrojoules, err := rz.GetEnergyMicrojoules() newMicrojoules, err := rz.GetEnergyMicrojoules()
if err != nil { if err != nil {
if errors.Is(err, os.ErrPermission) {
level.Debug(c.logger).Log("msg", "Can't access energy_uj file", "zone", rz, "err", err)
return ErrNoData
}
return err return err
} }
index := strconv.Itoa(rz.Index) index := strconv.Itoa(rz.Index)