needrestart
needrestart copied to clipboard
OpenMetrics output is not taken as valid by prometheus
Great.... I've previously implemented a new command-line flag for outputting information in OpenMetrics format in #308 and I was following the OpenMetrics spec document https://raw.githubusercontent.com/OpenObservability/OpenMetrics/main/specification/OpenMetrics.md
well it turns out that prometheus does not implement all of the spec and most of what needrestart outputs cannot be ingested by it :face_exhaling: see https://prometheus.io/docs/concepts/metric_types/
So I need to fix this up if we want ppl to be able to use the feature.
From what I've seen I need to fix the following issues:
- the labels for the
needrestart_build_infotimeseries are not properly quoted - prometheus does not support the
infometric type, we need to default to thegaugetype - prometheus does not support the
stateset, we need to default again to thegaugetype and rather have the value of thekernel_statuslabel change according to the status. the same needs to happen for the other stateset type series.
Note that this is actually a bug in the node exporter, not necessarily in Prometheus itself, see https://github.com/prometheus/node_exporter/issues/1988
We should nevertheless be conservative here and restrict ourselves to something the textfile collector supports by default, unless we plan on exporting those metrics some other way. Perhaps some flag could flip between -prometheus or -openmetrics, but i'm not sure it's worth that complexity...