prometheus/node_exporter · error

failed to get memory info

Error message

failed to get memory info: %w

What it means

getMemInfo calls fs.Meminfo() to parse /proc/meminfo and wraps any failure in this error. Since the procfs handle was already opened successfully in NewMeminfoCollector, this means the per-call read or parse of the meminfo file failed — e.g. the file is missing at read time, unreadable, or its contents could not be parsed by the procfs library.

Solutions

  1. Verify /proc/meminfo (or --path.procfs/meminfo) exists and is readable by the exporter process: `cat <procfs>/meminfo`
  2. If using lxcfs or proc-masking, ensure the presented meminfo format is standard or point --path.procfs at the real host procfs
  3. Check LSM/seccomp policies (AppArmor/SELinux/seccomp) that may block reads of /proc/meminfo and adjust the profile
  4. Update the prometheus/procfs dependency if the kernel's meminfo format changed (newer kernels can add fields); check `go get -u github.com/prometheus/procfs`
  5. As a workaround, run with --collector.meminfo disabled if the metric is not needed
Defensive patterns

Strategy: try-catch

Validate before calling

if f, err := os.Open(filepath.Join(procPath, "meminfo")); err != nil {
    log.Printf("/proc/meminfo unreadable: %v", err)
} else {
    f.Close()
}

Try / catch

// node_exporter surfaces this per-scrape; monitor scrape errors:
if err := c.Update(ch); err != nil {
    c.logger.Error("meminfo update failed", "err", err)
    // alert on node_scrape_collector_success{collector="meminfo"} == 0
}

Prevention

When it happens

Trigger: c.fs.Meminfo() errors during a scrape: /proc/meminfo disappeared or became unreadable between collector creation and the Update call, the procfs mount is stale/empty (e.g. container with masked /proc paths), or procfs returns a parse error because the kernel's meminfo format is unexpected.

Common situations: Containers using LSMs or runtimes that mask /proc/meminfo (e.g. some Kubernetes securityContext setups hiding /proc paths); corrupted or non-Linux procfs emulation (e.g. lxcfs remapping /proc/meminfo) producing unexpected format; host under severe memory/resource pressure causing read failures.

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/618df4953b0d7d26. Report an issue: GitHub.

Appendix: source

Thrown at collector/meminfo_linux.go:46

}

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

	return &meminfoCollector{
		logger: logger,
		fs:     fs,
	}, nil
}

func (c *meminfoCollector) getMemInfo() (map[string]float64, error) {
	meminfo, err := c.fs.Meminfo()
	if err != nil {
		return nil, fmt.Errorf("failed to get memory info: %w", err)
	}

	metrics := make(map[string]float64)

	if meminfo.ActiveBytes != nil {
		metrics["Active_bytes"] = float64(*meminfo.ActiveBytes)
	}
	if meminfo.ActiveAnonBytes != nil {
		metrics["Active_anon_bytes"] = float64(*meminfo.ActiveAnonBytes)
	}
	if meminfo.ActiveFileBytes != nil {
		metrics["Active_file_bytes"] = float64(*meminfo.ActiveFileBytes)
	}
	if meminfo.AnonHugePagesBytes != nil {
		metrics["AnonHugePages_bytes"] = float64(*meminfo.AnonHugePagesBytes)
	}
	if meminfo.AnonPagesBytes != nil {
		metrics["AnonPages_bytes"] = float64(*meminfo.AnonPagesBytes)

View on GitHub (pinned to 17ddd77c59)