{"record":{"id":"ac03255732519033","repo":"prometheus/node_exporter","slug":"failed-to-open-procfs-w-ac0325","errorCode":null,"errorMessage":"failed to open procfs: %w","messagePattern":"failed to open procfs: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"collector/mountstats_linux.go","lineNumber":124,"sourceCode":"\tMountAddress string\n}\n\ntype nfsMountpointIdentifier struct {\n\tDevice       string\n\tProtocol     string\n\tMountAddress string\n\tMountPoint   string\n}\n\nfunc init() {\n\tregisterCollector(\"mountstats\", defaultDisabled, NewMountStatsCollector)\n}\n\n// NewMountStatsCollector returns a new Collector exposing NFS statistics.\nfunc NewMountStatsCollector(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\tproc, err := fs.Self()\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to open /proc/self: %w\", err)\n\t}\n\n\tconst (\n\t\t// For the time being, only NFS statistics are available via this mechanism.\n\t\tsubsystem = \"mountstats_nfs\"\n\t)\n\n\tvar (\n\t\tlabels          = []string{\"export\", \"protocol\", \"mountaddr\"}\n\t\tinfoLabels      = []string{\"export\", \"protocol\", \"mountaddr\", \"mountpoint\"}\n\t\topLabels        = []string{\"export\", \"protocol\", \"mountaddr\", \"operation\"}\n\t\ttransportLabels = []string{\"export\", \"protocol\", \"mountaddr\", \"transport\"}\n\t)","sourceCodeStart":106,"sourceCodeEnd":142,"githubUrl":"https://github.com/prometheus/node_exporter/blob/17ddd77c59ba27e1508e9f7894b1e55b44d6aed3/collector/mountstats_linux.go#L106-L142","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Mount /proc into the container (e.g. docker run -v /proc:/host/proc:ro and pass --path.procfs=/host/proc)","Verify the flag: --path.procfs must point to a mounted procfs directory (check `mount | grep proc`)","Run node_exporter on Linux with procfs available; this collector is not usable on other OSes","Check container runtime security settings (e.g. maskedPaths in Kubernetes) and unmask /proc/self/mountstats if needed"],"exampleFix":"// before (container without /proc)\n// docker run prom/node-exporter  -> failed to open procfs\n// after\n// docker run -v /proc:/host/proc:ro prom/node-exporter \\\n//   --path.procfs=/host/proc","handlingStrategy":"validation","validationCode":"// check before starting the collector\ndef validateProcfs(path string) error {\n\tfs, err := procfs.NewFS(path)\n\tif err != nil { return err }\n\tif _, err := fs.Self(); err != nil { return err }\n\treturn nil\n}","typeGuard":null,"tryCatchPattern":"c, err := NewMountStatsCollector(logger)\nif err != nil {\n\tif strings.Contains(err.Error(), \"failed to open procfs\") {\n\t\tlogger.Error(\"procfs unavailable; NFS stats disabled\", \"err\", err)\n\t\treturn // skip registration, let the rest of the exporter run\n\t}\n\treturn err\n}","preventionTips":["Always mount /proc (or /host/proc) read-only into containers running node_exporter","Set --path.procfs explicitly when using a non-default mount point","Unmask /proc paths needed by exporters in Kubernetes securityContext","Only enable NFS/mountstats collectors on Linux hosts"],"tags":["linux","procfs","nfs","mountstats","collector-init"],"backgroundTag":"file-not-found","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"}