Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,22 @@ local labels = {
target = b.release.target
}

local os_info = {
Copy link
Copy Markdown
Author

@evgeni evgeni Apr 26, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

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,
}
Comment on lines +15 to +22
Copy link

Copilot AI Apr 28, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe read the whole file?


local b = nil
local u = nil
local ubus = nil

local function scrape()
metric("node_openwrt_info", "gauge", labels, 1)
metric("node_os_info", "gauge", os_info, 1)
Copy link

Copilot AI Apr 28, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
end

return { scrape = scrape }
Expand Down
Loading