{"record":{"id":"2d9e8757939acab1","repo":"prometheus/node_exporter","slug":"failed-to-open-procfs-w-2d9e87","errorCode":null,"errorMessage":"failed to open procfs: %w","messagePattern":"failed to open procfs: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"collector/nfsd_linux.go","lineNumber":48,"sourceCode":"type nfsdCollector struct {\n\tfs           nfs.FS\n\trequestsDesc *prometheus.Desc\n\tlogger       *slog.Logger\n}\n\nfunc init() {\n\tregisterCollector(\"nfsd\", defaultEnabled, NewNFSdCollector)\n}\n\nconst (\n\tnfsdSubsystem = \"nfsd\"\n)\n\n// NewNFSdCollector returns a new Collector exposing /proc/net/rpc/nfsd statistics.\nfunc NewNFSdCollector(logger *slog.Logger) (Collector, error) {\n\tfs, err := nfs.NewFS(*procPath)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to open procfs: %w\", err)\n\t}\n\n\treturn &nfsdCollector{\n\t\tfs: fs,\n\t\trequestsDesc: prometheus.NewDesc(\n\t\t\tprometheus.BuildFQName(namespace, nfsdSubsystem, \"requests_total\"),\n\t\t\t\"Total number NFSd Requests by method and protocol.\",\n\t\t\t[]string{\"proto\", \"method\"}, nil,\n\t\t),\n\t\tlogger: logger,\n\t}, nil\n}\n\n// Update implements Collector.\nfunc (c *nfsdCollector) Update(ch chan<- prometheus.Metric) error {\n\tstats, err := c.fs.ServerRPCStats()\n\tif err != nil {\n\t\tif errors.Is(err, os.ErrNotExist) {","sourceCodeStart":30,"sourceCodeEnd":66,"githubUrl":"https://github.com/prometheus/node_exporter/blob/17ddd77c59ba27e1508e9f7894b1e55b44d6aed3/collector/nfsd_linux.go#L30-L66","documentation":"NewNFSdCollector constructs the collector by calling nfs.NewFS(*procPath), which validates that the given procfs mount point exists and looks like a proc filesystem. If it cannot be opened (missing path, wrong path flag, or not a procfs mount), the constructor returns this wrapped error and no collector is created. This is a startup-time failure, not a scrape-time one.","triggerScenarios":"Calling NewNFSdCollector (directly or via node_exporter startup) when the --path.procfs flag points to a nonexistent directory or a directory that is not a procfs mount, causing nfs.NewFS to fail.","commonSituations":"Running node_exporter in a container without mounting the host /proc and forgetting --path.procfs=/host/proc; typo in --path.procfs; running on a system where the proc path was overridden for testing to an invalid value.","solutions":["Pass the correct procfs location: --path.procfs=/proc (or the mounted host path in containers).","Verify the directory exists and is a procfs mount: 'mount | grep proc' and 'ls /proc/net/rpc/nfsd'.","In containers, mount the host proc read-only, e.g. -v /proc:/host/proc:ro, and point --path.procfs at it.","Check the wrapped cause in the error to distinguish ENOENT (wrong path) from other failures."],"exampleFix":"// before: wrong proc path inside container\n//   ./node_exporter --collector.nfsd\n// after: mount and point at host procfs\n//   docker run -v /proc:/host/proc:ro node-exporter \\\n//     --path.procfs=/host/proc --collector.nfsd","handlingStrategy":"validation","validationCode":"// Go: validate proc path before constructing the collector\nst, err := os.Stat(filepath.Join(*procPath, \"net/rpc/nfsd\"))\nif err != nil || st.IsDir() {\n    log.Fatalf(\"invalid --path.procfs (%s): nfsd stats unavailable\", *procPath)\n}","typeGuard":null,"tryCatchPattern":"// constructor errors are fatal at startup; check and fail fast\nfs, err := nfs.NewFS(*procPath)\nif err != nil {\n    return nil, fmt.Errorf(\"failed to open procfs: %w\", err) // surface wrapped cause\n}","preventionTips":["Always confirm /proc/net/rpc/nfsd exists in the environment where you enable --collector.nfsd.","In containers, mount host /proc ro and set --path.procfs=/host/proc from day one.","Avoid overriding --path.procfs unless you know the mounted location.","Smoke-test new container images with the exact collector flags before rollout."],"tags":["linux","procfs","nfsd","startup","configuration"],"backgroundTag":"file-open-failed","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"}