prometheus/node_exporter · error

failed to open procfs

Error message

failed to open procfs: %w

What it means

NewSlabinfoCollector wraps the error from procfs.NewFS(*procPath) with 'failed to open procfs': the configured proc path could not be opened when constructing the slabinfo collector, so it never registers.

Solutions

  1. Point --path.procfs at a valid procfs mount (default /proc)
  2. Mount /proc into the container
  3. Check the path manually (ls /proc/slabinfo) before starting

Example fix

// before
node_exporter --path.procfs=/var/empty --collector.slabinfo
// after
node_exporter --path.procfs=/proc --collector.slabinfo
Defensive patterns

Strategy: validation

Validate before calling

func ensureProcfs(path string) error {
	if _, err := os.Stat(filepath.Join(path, "slabinfo")); err != nil {
		return fmt.Errorf("%q lacks slabinfo; not a usable procfs for this collector", path)
	}
	return nil
}

Try / catch

c, err := NewSlabinfoCollector(logger)
if err != nil {
	logger.Error("slabinfo collector not registered", "err", err)
}

Prevention

When it happens

Trigger: Enabling the slabinfo collector with --path.procfs set to a missing or invalid directory; procfs.NewFS validation fails during NewSlabinfoCollector.

Common situations: Container images without /proc mounted at the expected path; incomplete custom procfs snapshot directories; typo in --path.procfs.

Understand the failure class

Background: "open() failed", "failed to open file", "cannot create file" — what a file open error means and how to fix it — this error's family across 42 libraries.

Related errors


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

Appendix: source

Thrown at collector/slabinfo_linux.go:47

	slabNameExclude = kingpin.Flag("collector.slabinfo.slabs-exclude", "Regexp of slabs to exclude in slabinfo collector.").Default("").String()
)

type slabinfoCollector struct {
	fs             procfs.FS
	logger         *slog.Logger
	subsystem      string
	labels         []string
	slabNameFilter deviceFilter
}

func init() {
	registerCollector("slabinfo", defaultDisabled, NewSlabinfoCollector)
}

func NewSlabinfoCollector(logger *slog.Logger) (Collector, error) {
	fs, err := procfs.NewFS(*procPath)
	if err != nil {
		return nil, fmt.Errorf("failed to open procfs: %w", err)
	}

	return &slabinfoCollector{logger: logger,
		fs:             fs,
		subsystem:      "slabinfo",
		labels:         []string{"slab"},
		slabNameFilter: newDeviceFilter(*slabNameExclude, *slabNameInclude),
	}, nil
}

func (c *slabinfoCollector) Update(ch chan<- prometheus.Metric) error {
	slabinfo, err := c.fs.SlabInfo()
	if err != nil {
		return fmt.Errorf("couldn't get %s: %w", c.subsystem, err)
	}

	for _, slab := range slabinfo.Slabs {
		if c.slabNameFilter.ignored(slab.Name) {

View on GitHub (pinned to 17ddd77c59)