Add agent_version label to node_info metric#334
Open
gecube wants to merge 1 commit into
Open
Conversation
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>
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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The
node_infometric documentation lists three labels —hostname,kernel_versionandagent_version— but the agent only ever emitted the first two. Theagent_versionlabel 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
agent_versionlabel to thenode_infometric definition (appended last, so existing label positions are unchanged).flags.Version, injected via-ldflags -X), passed throughnode.NewCollector.node_info, so the positional label count stays consistent.No new metric is introduced: the
node_infoinfo-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:End-to-end: image built with
--build-arg VERSION=v1.99.0-agentver-test, run on a live host,/metricsscrape:The
agent_versionlabel matches the build-injected version, consistent with the existingnode_agent_info{version=...}series.Fixes #215