prometheus/node_exporter · error

failed to open procfs

Error message

failed to open procfs: %w

What it means

procfs.NewFS(*procPath) failed to initialize a procfs handle rooted at the --path.procfs value (default /proc). The underlying procfs library checks that the directory exists and is a readable proc mount (e.g. by stat-ing it and probing files like /proc/stat); this fires when the configured root path does not exist, is not mounted as procfs, or is unreadable by the exporter user — commonly a broken/missing /proc mount inside a minimal container or an invalid --path.procfs flag. The sentinel is generic: the wrapped %w error names the real cause (ENOENT, EACCES, or 'not a procfs filesystem'), while the faulting input is the procPath flag value itself.

Solutions

  1. Verify /proc is mounted and readable: ls -l /proc/stat and mount | grep ' type proc ' on the host running node_exporter.
  2. Check the --path.procfs flag value — it must be an existing procfs mount root (default /proc); fix typos or stale paths.
  3. In containers (distroless/scratch), ensure /proc is bind-mounted from the host and the container user can read it.
  4. Inspect the wrapped error in the log line — ENOENT means the path is absent, EACCES means a permissions issue (run with adequate privileges or fix ACLs).
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at collector/swap_linux.go:45 when the library encounters an invalid state.

Common situations: See trigger scenarios.


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

Appendix: source

Thrown at collector/swap_linux.go:45

	swapSubsystem = "swap"
)

var swapLabelNames = []string{"device", "swap_type"}

type swapCollector struct {
	fs     procfs.FS
	logger *slog.Logger
}

func init() {
	registerCollector("swap", defaultDisabled, NewSwapCollector)
}

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

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

type SwapsEntry struct {
	Device   string
	Type     string
	Priority int
	Size     int
	Used     int
}

func (c *swapCollector) getSwapInfo() ([]SwapsEntry, error) {
	swaps, err := c.fs.Swaps()

View on GitHub (pinned to 17ddd77c59)