{"record":{"id":"9c6012b0c2545fec","repo":"prometheus/node_exporter","slug":"failed-to-retrieve-nfs-stats-w","errorCode":null,"errorMessage":"failed to retrieve nfs stats: %w","messagePattern":"failed to retrieve nfs stats: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"collector/nfs_linux.go","lineNumber":104,"sourceCode":"\t\t),\n\t\tnfsProceduresDesc: prometheus.NewDesc(\n\t\t\tprometheus.BuildFQName(namespace, nfsSubsystem, \"requests_total\"),\n\t\t\t\"Number of NFS procedures invoked.\",\n\t\t\t[]string{\"proto\", \"method\"},\n\t\t\tnil,\n\t\t),\n\t\tlogger: logger,\n\t}, nil\n}\n\nfunc (c *nfsCollector) Update(ch chan<- prometheus.Metric) error {\n\tstats, err := c.fs.ClientRPCStats()\n\tif err != nil {\n\t\tif errors.Is(err, os.ErrNotExist) {\n\t\t\tc.logger.Debug(\"Not collecting NFS metrics\", \"err\", err)\n\t\t\treturn ErrNoData\n\t\t}\n\t\treturn fmt.Errorf(\"failed to retrieve nfs stats: %w\", err)\n\t}\n\n\tc.updateNFSNetworkStats(ch, &stats.Network)\n\tc.updateNFSClientRPCStats(ch, &stats.ClientRPC)\n\tc.updateNFSRequestsv2Stats(ch, &stats.V2Stats)\n\tc.updateNFSRequestsv3Stats(ch, &stats.V3Stats)\n\tc.updateNFSRequestsv4Stats(ch, &stats.ClientV4Stats)\n\n\treturn nil\n}\n\n// updateNFSNetworkStats collects statistics for network packets/connections.\nfunc (c *nfsCollector) updateNFSNetworkStats(ch chan<- prometheus.Metric, s *nfs.Network) {\n\tch <- prometheus.MustNewConstMetric(c.nfsNetReadsDesc, prometheus.CounterValue,\n\t\tfloat64(s.UDPCount), \"udp\")\n\tch <- prometheus.MustNewConstMetric(c.nfsNetReadsDesc, prometheus.CounterValue,\n\t\tfloat64(s.TCPCount), \"tcp\")\n\tch <- prometheus.MustNewConstMetric(c.nfsNetConnectionsDesc, prometheus.CounterValue,","sourceCodeStart":86,"sourceCodeEnd":122,"githubUrl":"https://github.com/prometheus/node_exporter/blob/17ddd77c59ba27e1508e9f7894b1e55b44d6aed3/collector/nfs_linux.go#L86-L122","documentation":"The NFS collector's Update calls fs.ClientRPCStats() to read /proc/net/rpc/nfs client RPC statistics via the procfs library. When that read fails with an error other than os.ErrNotExist (the common 'no NFS client' case, which is silently skipped as ErrNoData), the collector wraps the underlying error in this message. It means the /proc file exists but could not be opened, read, or parsed.","triggerScenarios":"c.fs.ClientRPCStats() returns a non-ErrNotExist error: e.g. permission failure reading /proc/net/rpc/nfs, a kernel producing malformed statistics text that procfs cannot parse, or a procfs library error opening the file.","commonSituations":"Running node_exporter in a container where /proc/net/rpc/nfs is masked or bind-mounted read-only with restricted permissions; unusual/custom kernels emitting unexpected /proc/net/rpc/nfs formatting; hardened LSM policies (SELinux/AppArmor) blocking reads of /proc/net/rpc.","solutions":["Verify node_exporter can read the file: run 'cat /proc/net/rpc/nfs' as the same user the exporter runs as.","Check container/namespace setup: mount host /proc (e.g. /host/proc via --path.procfs) so the NFS stats file is visible.","Inspect the wrapped cause (%w) in the log line to determine whether it is a parse error vs an open/permission error.","If the file is absent on hosts without NFS, treat this as expected behavior; the collector intentionally returns ErrNoData for os.ErrNotExist.","Update procfs/node_exporter if the cause is a parse failure on a newer kernel's stats format."],"exampleFix":"// before: collector fails every scrape on restricted /proc\n// after: run exporter with host procfs and read access\n//   docker run -v /proc:/host/proc:ro node-exporter --path.procfs=/host/proc\n// or in systemd:\n//   [Service]\n//   ReadOnlyPaths=/proc/net/rpc  # ensure this is NOT blocking reads","handlingStrategy":"try-catch","validationCode":"// Go: check readability before enabling the collector\nif f, err := os.Open(filepath.Join(*procPath, \"net/rpc/nfs\")); err != nil {\n    log.Printf(\"nfs stats not readable: %v\", err)\n} else {\n    f.Close()\n}","typeGuard":null,"tryCatchPattern":"// treat wrapped error: distinguish not-exist from real failures\nif errors.Is(err, os.ErrNotExist) {\n    return ErrNoData // expected on non-NFS hosts\n}\nreturn fmt.Errorf(\"failed to retrieve nfs stats: %w\", err) // log cause, alert on persistence","preventionTips":["Run node_exporter with read access to /proc/net/rpc (check with sudo -u exporter cat /proc/net/rpc/nfs).","In containers, mount host /proc read-only and pass --path.procfs.","Only enable --collector.nfs on hosts that actually use NFS.","Alert on scrape error metrics rather than treating single failures as fatal."],"tags":["linux","procfs","nfs","collector"],"backgroundTag":"file-read-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"}