Skip to content

Add agent_version label to node_info metric#334

Open
gecube wants to merge 1 commit into
coroot:mainfrom
gecube:fix_215_node_info_agent_version
Open

Add agent_version label to node_info metric#334
gecube wants to merge 1 commit into
coroot:mainfrom
gecube:fix_215_node_info_agent_version

Conversation

@gecube

@gecube gecube commented Jul 6, 2026

Copy link
Copy Markdown

Problem

The node_info metric documentation lists three labels — hostname, kernel_version and agent_version — but the agent only ever emitted the first two. The agent_version label was never present, as noted in the comment on #215.

This closes the documentation/implementation gap and gives the backend the data it needs to surface the agent version in the UI and to warn when an agent falls behind (the feature requested in #215).

Change

  • Add the agent_version label to the node_info metric definition (appended last, so existing label positions are unchanged).
  • Populate it with the build-time version (flags.Version, injected via -ldflags -X), passed through node.NewCollector.
  • Update both the Linux and Windows collectors, which each emit node_info, so the positional label count stays consistent.

No new metric is introduced: the node_info info-metric is the contract the docs already promise, and its cardinality only changes across upgrades — the standard info-metric pattern.

Verification

Unit test (node/collector_agent_version_test.go) asserting the label is present with the expected value:

=== RUN   TestNodeInfoIncludesAgentVersion
--- PASS: TestNodeInfoIncludesAgentVersion (0.00s)
PASS
ok  	github.com/coroot/coroot-node-agent/node	0.002s

End-to-end: image built with --build-arg VERSION=v1.99.0-agentver-test, run on a live host, /metrics scrape:

node_info{agent_version="v1.99.0-agentver-test",hostname="orbstack",kernel_version="7.0.11-orbstack-00360-gc9bc4d96ac70",machine_id="82ddc538b9e95ae7c1d309201ccb5f9d",system_uuid=""} 1

The agent_version label matches the build-injected version, consistent with the existing node_agent_info{version=...} series.

Fixes #215

The documentation for node_info
(https://docs.coroot.com/metrics/node-agent/#node_info) lists an
agent_version label, but the metric never exposed it. Populate the
label with the build-time agent version (flags.Version) so the agent
version is discoverable from metrics, matching the docs and enabling
version display / staleness checks (issue coroot#215).

Both the Linux and Windows collectors emit node_info, so both pass the
version through the collector.

Signed-off-by: Gaál György <gb12335@gmail.com>
@def

def commented Jul 6, 2026

Copy link
Copy Markdown
Member

@gecube could you please stop bombing the Coroot repos with AI-generated PRs like this one? It doesn't solve any real problem and doesn't help the project.

@def def added the AI slop label Jul 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature request. Present agent version

2 participants