prometheus/node_exporter · error

couldn't get buddyinfo

Error message

couldn't get buddyinfo: %w

What it means

buddyinfoCollector.Update wraps errors from c.fs.BuddyInfo() in "couldn't get buddyinfo". Reading /proc/buddyinfo failed during a scrape even though the procfs handle was created successfully. All node_buddy metrics are skipped for that scrape cycle.

Solutions

  1. Check that /proc/buddyinfo exists and is readable (cat /proc/buddyinfo) as the exporter user
  2. Verify no security module or seccomp profile blocks access to /proc/buddyinfo
  3. Upgrade the prometheus/procfs dependency if the kernel emits a changed buddyinfo format
  4. Disable the buddyinfo collector if /proc/buddyinfo is intentionally unavailable in your environment

Example fix

// before
 if err := updater.Update(ch); err != nil {
	return err
 }
// after
 if err := updater.Update(ch); err != nil {
	logger.Warn("buddyinfo scrape failed; continuing", "err", err)
	return nil // tolerate missing /proc/buddyinfo
 }
Defensive patterns

Strategy: try-catch

Validate before calling

if _, err := os.Stat("/proc/buddyinfo"); err != nil { /* collector will error; skip */ }

Try / catch

err := collector.Update(ch)
if err != nil {
	if strings.Contains(err.Error(), "couldn't get buddyinfo") {
		logger.Warn("buddyinfo unavailable; skipping", "err", err)
		return nil
	}
	return err
}

Prevention

When it happens

Trigger: A scrape where /proc/buddyinfo cannot be opened or parsed: the file was removed (unusual kernel builds with CONFIG_PROC_FS restrictions), a container lost procfs visibility after start, or /proc/buddyinfo content does not match the parser's expected format on unusual kernels.

Common situations: Hardened kernels or seccomp/LSM setups hiding /proc/buddyinfo; NUMA-less or vendor kernels with nonstandard buddyinfo layout; procfs remounted read-only or hidden in containers mid-run.

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/59bb9824b1d05aff. Report an issue: GitHub.

Appendix: source

Thrown at collector/buddyinfo.go:62

		[]string{"node", "zone", "size"}, nil,
	)
)

// NewBuddyinfoCollector returns a new Collector exposing buddyinfo stats.
func NewBuddyinfoCollector(logger *slog.Logger) (Collector, error) {
	fs, err := procfs.NewFS(*procPath)
	if err != nil {
		return nil, fmt.Errorf("failed to open procfs: %w", err)
	}
	return &buddyinfoCollector{fs, logger}, nil
}

// Update calls (*buddyinfoCollector).getBuddyInfo to get the platform specific
// buddyinfo metrics.
func (c *buddyinfoCollector) Update(ch chan<- prometheus.Metric) error {
	buddyInfo, err := c.fs.BuddyInfo()
	if err != nil {
		return fmt.Errorf("couldn't get buddyinfo: %w", err)
	}

	c.logger.Debug("Set node_buddy", "buddyInfo", buddyInfo)
	for _, entry := range buddyInfo {
		for size, value := range entry.Sizes {
			ch <- prometheus.MustNewConstMetric(
				buddyinfoBlocks,
				prometheus.GaugeValue, value,
				entry.Node, entry.Zone, strconv.Itoa(size),
			)
		}
	}
	return nil
}

View on GitHub (pinned to 17ddd77c59)