prometheus/node_exporter · error

failed to open procfs

Error message

failed to open procfs: %w

What it means

NewMountStatsCollector opens the procfs filesystem via procfs.NewFS(*procPath) (default /proc) before collecting NFS mount statistics. If /proc cannot be mounted/opened, collector construction fails with this wrapped error. node_exporter throws it because the NFS stats collector fundamentally depends on reading /proc/self/mountstats.

Solutions

  1. Mount /proc into the container (e.g. docker run -v /proc:/host/proc:ro and pass --path.procfs=/host/proc)
  2. Verify the flag: --path.procfs must point to a mounted procfs directory (check `mount | grep proc`)
  3. Run node_exporter on Linux with procfs available; this collector is not usable on other OSes
  4. Check container runtime security settings (e.g. maskedPaths in Kubernetes) and unmask /proc/self/mountstats if needed

Example fix

// before (container without /proc)
// docker run prom/node-exporter  -> failed to open procfs
// after
// docker run -v /proc:/host/proc:ro prom/node-exporter \
//   --path.procfs=/host/proc
Defensive patterns

Strategy: validation

Validate before calling

// check before starting the collector
def validateProcfs(path string) error {
	fs, err := procfs.NewFS(path)
	if err != nil { return err }
	if _, err := fs.Self(); err != nil { return err }
	return nil
}

Try / catch

c, err := NewMountStatsCollector(logger)
if err != nil {
	if strings.Contains(err.Error(), "failed to open procfs") {
		logger.Error("procfs unavailable; NFS stats disabled", "err", err)
		return // skip registration, let the rest of the exporter run
	}
	return err
}

Prevention

When it happens

Trigger: Creating the mountstats collector when the path in --path.procfs does not exist or is not a procfs mount — common when running in a container without /proc mounted or with a custom procfs path that is wrong.

Common situations: Docker/Kubernetes containers where /proc is not mounted or is masked; typo'd --path.procfs flag; running on hosts without procfs (non-Linux build mistakenly deployed); read-only rootfs missing the mount.

Understand the failure class

Background: "File not found" and ENOENT errors: why libraries can't find a file that should exist — this error's family across 50 libraries.

Related errors


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

Appendix: source

Thrown at collector/mountstats_linux.go:124

	MountAddress string
}

type nfsMountpointIdentifier struct {
	Device       string
	Protocol     string
	MountAddress string
	MountPoint   string
}

func init() {
	registerCollector("mountstats", defaultDisabled, NewMountStatsCollector)
}

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

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

	const (
		// For the time being, only NFS statistics are available via this mechanism.
		subsystem = "mountstats_nfs"
	)

	var (
		labels          = []string{"export", "protocol", "mountaddr"}
		infoLabels      = []string{"export", "protocol", "mountaddr", "mountpoint"}
		opLabels        = []string{"export", "protocol", "mountaddr", "operation"}
		transportLabels = []string{"export", "protocol", "mountaddr", "transport"}
	)

View on GitHub (pinned to 17ddd77c59)