needrestart icon indicating copy to clipboard operation
needrestart copied to clipboard

OpenMetrics output is not taken as valid by prometheus

Open lelutin opened this issue 1 year ago • 1 comments

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_info timeseries are not properly quoted
  • prometheus does not support the info metric type, we need to default to the gauge type
  • prometheus does not support the stateset, we need to default again to the gauge type and rather have the value of the kernel_status label change according to the status. the same needs to happen for the other stateset type series.

lelutin avatar Aug 28 '24 21:08 lelutin

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...

anarcat avatar Aug 29 '24 14:08 anarcat