netstat: model legacy TcpExt counters removed from recent kernels - #863
Merged
Merged
Conversation
Member
|
This needs a DCO sign-off. You can use |
SuperQ
approved these changes
Aug 27, 2026
PAWSPassive, TCPPrequeued, TCPDirectCopyFromBacklog, TCPDirectCopyFromPrequeue, TCPPrequeueDropped, TCPLoss, TCPFACKReorder, TCPForwardRetrans, TCPHPHitsToUser and TCPSchedulerFailed are absent from the current kernel TcpExt table but are still printed by older kernels. Model them so consumers keep metric parity with older kernels; the parser stays additive (absent keys remain nil). See prometheus/node_exporter#3796. Signed-off-by: 霏承 <huangleshu.hls@alibaba-inc.com>
neoLsH
force-pushed
the
add-legacy-tcpext-counters
branch
from
August 27, 2026 10:07
d0574f8 to
cc6d988
Compare
neoLsH
added a commit
to neoLsH/node_exporter
that referenced
this pull request
Aug 28, 2026
procfs v0.22.0 includes prometheus/procfs#863, which models the 10 legacy TcpExt counters. With this bump, the explicit descriptors already present in netstat_descs_linux.go start populating for users whose field regex selects them, restoring parity with older kernels. Part of prometheus#3796. Signed-off-by: 霏承 <huangleshu.hls@alibaba-inc.com>
neoLsH
added a commit
to neoLsH/node_exporter
that referenced
this pull request
Aug 28, 2026
procfs v0.22.0 includes prometheus/procfs#863, which models the 10 legacy TcpExt counters. With this bump, the explicit descriptors already present in netstat_descs_linux.go start populating for users whose field regex selects them, restoring parity with older kernels. Part of prometheus#3796. Signed-off-by: 霏承 <huangleshu.hls@alibaba-inc.com>
SuperQ
pushed a commit
to prometheus/node_exporter
that referenced
this pull request
Aug 31, 2026
* netstat: Use procfs parsers for netstat, snmp and snmp6 Replace the hand-written parsers for /proc/net/netstat, /proc/net/snmp and /proc/net/snmp6 with the parsers from prometheus/procfs (Proc.Netstat, Proc.Snmp and Proc.Snmp6). The statistics are read via /proc/self/net, which is equivalent to /proc/net (both are network-namespace local views of the current process), so the collected data is unchanged. Metrics are exposed by iterating the procfs statistics structs, the same approach the NFS collector uses: fields are *float64 and only the ones present on the system are exported, matching the previous behavior. The --collector.netstat.fields flag and the exported metric names are unchanged; the e2e golden output is identical. Signed-off-by: neoLsH <43921685+neoLsH@users.noreply.github.com> * netstat: use explicit package-level metric descriptors Replace the per-scrape prometheus.NewDesc calls with a pre-built map of explicit descriptors (netstat_descs_linux.go, generated from the procfs statistics structs), as requested in review. Collection still reflects over the procfs structs but looks up the descriptor by "<protocol>_<field>", so descriptors are allocated once and are source-visible literals for the AST-based doc generation. Metric names, help strings and types are unchanged. Signed-off-by: 霏承 <huangleshu.hls@alibaba-inc.com> * Bump procfs to v0.22.0 to populate legacy TcpExt descriptors procfs v0.22.0 includes prometheus/procfs#863, which models the 10 legacy TcpExt counters. With this bump, the explicit descriptors already present in netstat_descs_linux.go start populating for users whose field regex selects them, restoring parity with older kernels. Part of #3796. Signed-off-by: 霏承 <huangleshu.hls@alibaba-inc.com> * Add generator and drift test for the netstat descriptor table netstat_descs_linux.go was previously committed without its generator. Add an in-repo generator (netstat_descs_gen.go, a build-ignored program run via GOOS=linux go generate ./collector) that regenerates the explicit descriptor table from the procfs structs, mirroring the go:generate pattern used elsewhere in the Prometheus ecosystem. Add TestNetStatDescsInSync, a drift test that fails if the committed table diverges from the procfs structs (e.g. after a procfs upgrade) until the table is regenerated. Part of #3796. Signed-off-by: 霏承 <huangleshu.hls@alibaba-inc.com> --------- Signed-off-by: neoLsH <43921685+neoLsH@users.noreply.github.com> Signed-off-by: 霏承 <huangleshu.hls@alibaba-inc.com>
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.
What
Add 10 legacy
TcpExtcounters to the/proc/net/netstatmodel and parser:PAWSPassive,TCPPrequeued,TCPDirectCopyFromBacklog,TCPDirectCopyFromPrequeue,TCPPrequeueDropped,TCPLoss,TCPFACKReorder,TCPForwardRetrans,TCPHPHitsToUser,TCPSchedulerFailed.Why
These counters are absent from the current kernel's
TcpExttable (none ofthem are in linus/master
include/uapi/linux/snmp.h), but older kernels stillprint them in
/proc/net/netstat. node_exporter is switching its netstatcollector to these parsers (prometheus/node_exporter#3796), and would
otherwise silently drop these metrics for users whose
--collector.netstat.fieldsregex selects them.Behavior
*float64and staynilwhen the kerneldoes not print them (all modern kernels), matching the optional-field
semantics from Replace float64 with *float64 for proc_netstat, proc_snmp and proc_snmp6 #464.
cases.
Out of scope
IcmpMsg/Icmp6Msgper-type counters: the kernel only prints non-zeroInTypeN/OutTypeNentries, so the set is host-dependent and open-ended —a fixed struct can't cover it (a map, like
NetDev, or an unknown-keysescape hatch would). Separate follow-up.
StatValuerefactor floated in netstat: Use procfs parsers for netstat, snmp and snmp6 node_exporter#3796: changingall netstat/snmp field types would be a breaking API change for existing
consumers; separate discussion.
Note on scope: this PR closes the backward gap (counters older kernels print that
were never modeled). procfs's
TcpExtalso lags the current kernel in the otherdirection (e.g.
TCPDelivered,TCPAckCompressed,TCPZeroWindowDrop,TCPBacklogCoalesce,BeyondWindow,TCPTimeoutRehash,TCPDSACKRecvSegs,TCPMigrateReq*,TCPAO*are printed by modern kernels but not modeled). Thatforward lag is procfs's ordinary upkeep, pre-exists this change, and affects all
consumers; it is deliberately out of scope here rather than bundled in.