prometheus-node-exporter-lua: expose node_os_info#29247
prometheus-node-exporter-lua: expose node_os_info#29247evgeni wants to merge 1 commit intoopenwrt:masterfrom
Conversation
the original node_exporter exposes a node_os_info metric with a set of data about the system [1] which is then used by several dashboards. openwrt.lua already exposes OS info, but using the node_openwrt_info metric requires changes to existing dashboards, and would require more complex lookups when there are non-OpenWrt hosts in the overview too. as we've already called ubus and fetched the data, we can expose it in two formats easily. [1] https://github.com/prometheus/node_exporter/blob/d6d0e710bb7daf07a2743fde060f0d5f32c565f3/collector/os_release.go#L190-L192 Signed-off-by: Evgeni Golov <evgeni@golov.de>
9b376dd to
9336c9d
Compare
| target = b.release.target | ||
| } | ||
|
|
||
| local os_info = { |
There was a problem hiding this comment.
the original node exporter also has the following fields: id_like, image_id, image_version, variant, variant_id version_codename, but as they are not part of the system board call, I skipped them here (only id_like is present in OpenWrts /etc/os-release).
the og exporter reports
node_os_info{build_id="r32802-f505120278",id="openwrt",id_like="lede openwrt",image_id="",image_version="",name="OpenWrt",pretty_name="OpenWrt 25.12.2",variant="",variant_id="",version="25.12.2",version_codename="",version_id="25.12.2"} 1
on my system, while the code here does
node_os_info{pretty_name="OpenWrt 25.12.2",name="OpenWrt",build_id="r32802-f505120278",id="openwrt",version_id="25.12.2",version="25.12.2"} 1
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Expose OpenWrt OS release metadata via the standard node_os_info metric (in addition to the existing node_openwrt_info) to keep compatibility with existing Prometheus dashboards that expect node_exporter’s metric names/labels.
Changes:
- Add an
os_infolabel-set derived from OpenWrt release data. - Emit a new
node_os_infogauge metric alongsidenode_openwrt_info.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| local os_info = { | ||
| id = string.lower(b.release.distribution), | ||
| name = b.release.distribution, | ||
| pretty_name = b.release.distribution .. " " .. b.release.version, | ||
| version = b.release.version, | ||
| version_id = b.release.version, | ||
| build_id = b.release.revision, | ||
| } |
There was a problem hiding this comment.
os_info is built at module load time and dereferences b.release.*. In this diff, b is declared later (and initialized to nil), which makes this table construction prone to failing with attempt to index a nil value during require()/module load. Construct os_info only after the ubus/os-release data has been fetched (e.g., inside scrape() right before emitting the metric, or in whatever init path populates b) so the collector won’t fail to load.
|
|
||
| local function scrape() | ||
| metric("node_openwrt_info", "gauge", labels, 1) | ||
| metric("node_os_info", "gauge", os_info, 1) |
There was a problem hiding this comment.
For maximum drop-in compatibility with node_exporter dashboards, node_os_info should expose the same label set as node_exporter’s node_os_info (node_exporter includes additional labels such as id_like, variant, variant_id, version_codename, etc.). Consider adding the missing label keys (using empty strings when OpenWrt doesn’t provide a value) so queries and label-based joins don’t break or require special-casing.
📦 Package Details
Maintainer: @champtar
Description:
the original node_exporter exposes a node_os_info metric with a set of data about the system [1] which is then used by several dashboards.
openwrt.lua already exposes OS info, but using the node_openwrt_info metric requires changes to existing dashboards, and would require more complex lookups when there are non-OpenWrt hosts in the overview too.
as we've already called ubus and fetched the data, we can expose it in two formats easily.
[1] https://github.com/prometheus/node_exporter/blob/d6d0e710bb7daf07a2743fde060f0d5f32c565f3/collector/os_release.go#L190-L192
🧪 Run Testing Details
But should work everywhere else too, that's just the env I tested the change in :)
✅ Formalities
If your PR contains a patch:
git am(e.g., subject line, commit description, etc.)
We must try to upstream patches to reduce maintenance burden.