From 4d61e6732729dc90ac630d11175bc0979367ac49 Mon Sep 17 00:00:00 2001 From: "Tom M." Date: Thu, 10 Oct 2024 22:07:11 +0200 Subject: [PATCH] Do not report unavailable values as NaN I am currently creating a Grafana dashboard for the ipmi exporter. And I find it incredibly difficult to deal with NaN values. For example, I want to calculate the average power consumption. But when a node is powered off, the power consumption is reported as NaN. Hence the entire result become none. My attempt to join the query with `ipmi_power_state` and to assume a default value instead of NaN while the node is powered off have been futile. In Prometheus, it is good practice to skip missing values. In this case, a simple `or` in the Prometheus query could be used to deal with the missing values. So, please consider to simply skip unavailable values rather than reporting them as NaN. --- collector.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/collector.go b/collector.go index 200d0e9..d8c5b6d 100644 --- a/collector.go +++ b/collector.go @@ -347,7 +347,7 @@ func splitSensorOutput(impitoolOutput string) ([]sensorData, error) { } else if valueS != "na" && convErr == nil { data.Value = float64(convValueS) } else { - data.Value = math.NaN() + continue } data.Type = splittedL[2] data.State = splittedL[3]