{"record":{"id":"3831e4db921ae31d","repo":"prometheus/node_exporter","slug":"failed-to-open-procfs-w-3831e4","errorCode":null,"errorMessage":"failed to open procfs: %w","messagePattern":"failed to open procfs: %w","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"collector/swap_linux.go","lineNumber":45,"sourceCode":"\tswapSubsystem = \"swap\"\n)\n\nvar swapLabelNames = []string{\"device\", \"swap_type\"}\n\ntype swapCollector struct {\n\tfs     procfs.FS\n\tlogger *slog.Logger\n}\n\nfunc init() {\n\tregisterCollector(\"swap\", defaultDisabled, NewSwapCollector)\n}\n\n// NewSwapCollector returns a new Collector exposing swap device statistics.\nfunc NewSwapCollector(logger *slog.Logger) (Collector, error) {\n\tfs, err := procfs.NewFS(*procPath)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to open procfs: %w\", err)\n\t}\n\n\treturn &swapCollector{\n\t\tfs:     fs,\n\t\tlogger: logger,\n\t}, nil\n}\n\ntype SwapsEntry struct {\n\tDevice   string\n\tType     string\n\tPriority int\n\tSize     int\n\tUsed     int\n}\n\nfunc (c *swapCollector) getSwapInfo() ([]SwapsEntry, error) {\n\tswaps, err := c.fs.Swaps()","sourceCodeStart":27,"sourceCodeEnd":63,"githubUrl":"https://github.com/prometheus/node_exporter/blob/17ddd77c59ba27e1508e9f7894b1e55b44d6aed3/collector/swap_linux.go#L27-L63","documentation":"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.","triggerScenarios":"Thrown at collector/swap_linux.go:45 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Verify /proc is mounted and readable: ls -l /proc/stat and mount | grep ' type proc ' on the host running node_exporter.","Check the --path.procfs flag value — it must be an existing procfs mount root (default /proc); fix typos or stale paths.","In containers (distroless/scratch), ensure /proc is bind-mounted from the host and the container user can read it.","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)."],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"17ddd77c59ba27e1508e9f7894b1e55b44d6aed3","analyzedAt":"2026-09-07T17:54:06.211Z","contentChangedAt":"2026-09-07T17:54:06.211Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}