prometheus/node_exporter · error

couldn't get SNMP stats

Error message

couldn't get SNMP stats: %w

What it means

The netstat collector's Update reads /proc/net/snmp via the procfs library (proc.Snmp()). If reading or parsing that file fails, Update returns this wrapped error, failing the collection of SNMP (non-SNMP6) network statistics.

Solutions

  1. Verify /proc/net/snmp exists and is readable (cat /proc/net/snmp).
  2. Update prometheus/procfs and node_exporter to versions compatible with your kernel.
  3. Check hidepid/proc mount options so the exporter user can read /proc/net.
  4. If only SNMP parsing fails while netstat works, file an upstream issue with the kernel version and file contents.

Example fix

// before
snmpStats, err := c.proc.Snmp()
if err != nil {
	return fmt.Errorf("couldn't get SNMP stats: %w", err)
}
// after (contextual wrap for diagnosability)
snmpStats, err := c.proc.Snmp()
if err != nil {
	return fmt.Errorf("couldn't get SNMP stats from %s/proc/net/snmp: %w", *procPath, err)
}
Defensive patterns

Strategy: try-catch

Validate before calling

import "os"
// Verify SNMP file readability before the scrape:
if f, err := os.Open(*procPath + "/self/net/snmp"); err != nil {
	// SNMP metrics unavailable; alert or skip
} else {
	f.Close()
}

Type guard

null

Try / catch

// Treat parse failures distinctly from missing files
if err := c.Update(ch); err != nil {
	var perr *os.PathError
	if errors.As(err, &perr) {
		logger.Warn("/proc/net/snmp unreadable", "err", err)
	} else {
		logger.Error("SNMP parse failure; update procfs library", "err", err)
	}
}

Prevention

When it happens

Trigger: c.proc.Snmp() errors when /proc/net/snmp is missing, unreadable, or contains content the procfs parser cannot parse (unexpected header/lines).

Common situations: Stripped /proc in containers; kernel/procfs library version skew producing unparseable output; permission restrictions on /proc/net.

Understand the failure class

Background: "failed to read file", EACCES, ENOENT and "could not read <path>" errors: when a program can't read a file from disk — this error's family across 49 libraries.

Related errors


AI-assisted analysis of prometheus/node_exporter@17ddd77c59 (2026-09-07). Data as JSON: /api/errors/8afb575efb5387a0. Report an issue: GitHub.

Appendix: source

Thrown at collector/netstat_linux.go:86

	if err != nil {
		return nil, fmt.Errorf("failed to open /proc/self: %w", err)
	}

	return &netStatCollector{
		proc:         proc,
		fieldPattern: pattern,
		logger:       logger,
	}, nil
}

func (c *netStatCollector) Update(ch chan<- prometheus.Metric) error {
	netStats, err := c.proc.Netstat()
	if err != nil {
		return fmt.Errorf("couldn't get netstats: %w", err)
	}
	snmpStats, err := c.proc.Snmp()
	if err != nil {
		return fmt.Errorf("couldn't get SNMP stats: %w", err)
	}
	snmp6Stats, err := c.proc.Snmp6()
	if err != nil {
		return fmt.Errorf("couldn't get SNMP6 stats: %w", err)
	}

	c.emitStruct(ch, netStats.TcpExt)
	c.emitStruct(ch, netStats.IpExt)
	c.emitStruct(ch, snmpStats.Ip)
	c.emitStruct(ch, snmpStats.Icmp)
	c.emitStruct(ch, snmpStats.IcmpMsg)
	c.emitStruct(ch, snmpStats.Tcp)
	c.emitStruct(ch, snmpStats.Udp)
	c.emitStruct(ch, snmpStats.UdpLite)
	c.emitStruct(ch, snmp6Stats.Ip6)
	c.emitStruct(ch, snmp6Stats.Icmp6)
	c.emitStruct(ch, snmp6Stats.Udp6)
	c.emitStruct(ch, snmp6Stats.UdpLite6)

View on GitHub (pinned to 17ddd77c59)