{"record":{"id":"ae8967dcae52d74a","repo":"prometheus/node_exporter","slug":"failed-to-open-procfs-w-ae8967","errorCode":null,"errorMessage":"failed to open procfs: %w","messagePattern":"failed to open procfs: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"collector/xfrm.go","lineNumber":39,"sourceCode":"\n\t\"github.com/prometheus/client_golang/prometheus\"\n\t\"github.com/prometheus/procfs\"\n)\n\ntype xfrmCollector struct {\n\tfs     procfs.FS\n\tlogger *slog.Logger\n}\n\nfunc init() {\n\tregisterCollector(\"xfrm\", defaultDisabled, NewXfrmCollector)\n}\n\n// NewXfrmCollector returns a new Collector exposing XFRM stats.\nfunc NewXfrmCollector(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 &xfrmCollector{\n\t\tfs:     fs,\n\t\tlogger: logger,\n\t}, nil\n}\n\nvar (\n\txfrmInErrorDesc = prometheus.NewDesc(\n\t\tprometheus.BuildFQName(namespace, \"xfrm\", \"in_error_packets_total\"),\n\t\t\"All errors not matched by other\",\n\t\tnil, nil,\n\t)\n\txfrmInBufferErrorDesc = prometheus.NewDesc(\n\t\tprometheus.BuildFQName(namespace, \"xfrm\", \"in_buffer_error_packets_total\"),\n\t\t\"No buffer is left\",\n\t\tnil, nil,","sourceCodeStart":21,"sourceCodeEnd":57,"githubUrl":"https://github.com/prometheus/node_exporter/blob/17ddd77c59ba27e1508e9f7894b1e55b44d6aed3/collector/xfrm.go#L21-L57","documentation":"NewXfrmCollector constructs a procfs.FS rooted at the --path.procfs flag and fails immediately if the filesystem cannot be opened/validated. The xfrm collector reads /proc/net/stat/xfrm_statistics via procfs; if the procfs mount point is inaccessible the collector constructor returns this wrapped error and the collector is never registered.","triggerScenarios":"procfs.NewFS(*procPath) fails because the path given by --path.procfs does not exist, is not a directory, or cannot be accessed — raised at collector construction time (also reproduced directly by TestXfrmStats in tests).","commonSituations":"Passing a wrong --path.procfs when running node_exporter in a container with a bind-mounted /proc at a different location, pointing procfs at a host mount that isn't mounted yet, running tests without a realistic /proc (the test uses a fixture path), chroot environments lacking /proc.","solutions":["Verify the --path.procfs value points to a valid procfs mount (ls <path>/net/stat/xfrm_statistics must work).","In containers, bind-mount the host's /proc (e.g. -v /proc:/host/proc:ro and --path.procfs=/host/proc).","Ensure /proc is mounted before node_exporter starts (startup ordering / mount namespace setup).","Since xfrm is disabled by default, simply don't enable it (--collector.xfrm) if not needed.","Check permissions on the procfs path for the user running node_exporter."],"exampleFix":"// before\nnode_exporter --collector.xfrm --path.procfs=/host/proc   # /host/proc not mounted\n// after\ndocker run -v /proc:/host/proc:ro ... node_exporter --collector.xfrm --path.procfs=/host/proc","handlingStrategy":"validation","validationCode":"// Go: validate the procfs root before constructing the collector\np := *procPath\nif fi, err := os.Stat(filepath.Join(p, \"net\", \"stat\", \"xfrm_statistics\")); err != nil || fi.IsDir() {\n    // xfrm stats unavailable at this procfs path; don't enable the xfrm collector\n}\nif fi, err := os.Stat(p); err != nil || !fi.IsDir() {\n    log.Fatalf(\"procfs path %q is not a directory\", p)\n}","typeGuard":null,"tryCatchPattern":"coll, err := collector.NewXfrmCollector(logger)\nif err != nil {\n    if strings.Contains(err.Error(), \"failed to open procfs\") {\n        logger.Warn(\"procfs unavailable; xfrm collector disabled\", \"err\", err)\n        coll = nil\n    } else {\n        return err\n    }\n}","preventionTips":["Always pass --path.procfs matching where /proc is actually mounted (especially in containers)","Bind-mount host /proc read-only when running in Docker/Kubernetes","Mount /proc before starting node_exporter in minimal/chroot environments","Remember xfrm is disabled by default — only enable it on Linux hosts with /proc/net/stat/xfrm_statistics"],"tags":["procfs","linux","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"}