prometheus-nixos-exporter: don't expose kernel store path
By exposing the store path we create multiple metrics for the same host after switching to a new kernel. This may result in receiving out of date alerts. The decision to remove this label is preferable to writing a much more complex query.
Martin Weinelt committed
Feb 27, 2024 at 13:24 UTC
0419f280292c0779e4438b54edd9b8890679d50d
1 file changed
+2
-4
modules/prometheus/nixos-exporter/prometheus_nixos_exporter/__main__.py
+2
-4
@@ -56,14 +56,12 @@ class NixosSystemCollector:
56
current_system_kernel_booted = GaugeMetricFamily(
57
"nixos_current_system_kernel_booted",
58
"Whether the currently booted kernel matches the one in the current generation.",
59
- labels=["booted", "current"],
59
+ labels=[],
60
)
61
booted_kernel = self.get_kernel_out("/run/booted-system")
62
current_kernel = self.get_kernel_out("/run/current-system")
63
64
- current_system_kernel_booted.add_metric(
65
- [booted_kernel, current_kernel], booted_kernel == current_kernel
66
- )
64
+ current_system_kernel_booted.add_metric([], booted_kernel == current_kernel)
65
yield current_system_kernel_booted
66
67
def get_version_id(self, path):