{"record":{"id":"05869fb00922ee21","repo":"prometheus/node_exporter","slug":"failed-to-open-procfs-w-05869f","errorCode":null,"errorMessage":"failed to open procfs: %w","messagePattern":"failed to open procfs: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"collector/cpu_linux.go","lineNumber":77,"sourceCode":"const jumpBackSeconds = 3.0\n\nvar (\n\tenableCPUGuest       = kingpin.Flag(\"collector.cpu.guest\", \"Enables metric node_cpu_guest_seconds_total\").Default(\"true\").Bool()\n\tenableCPUInfo        = kingpin.Flag(\"collector.cpu.info\", \"Enables metric cpu_info\").Bool()\n\tflagsInclude         = kingpin.Flag(\"collector.cpu.info.flags-include\", \"Filter the `flags` field in cpuInfo with a value that must be a regular expression\").String()\n\tbugsInclude          = kingpin.Flag(\"collector.cpu.info.bugs-include\", \"Filter the `bugs` field in cpuInfo with a value that must be a regular expression\").String()\n\tjumpBackDebugMessage = fmt.Sprintf(\"CPU Idle counter jumped backwards more than %f seconds, possible hotplug event, resetting CPU stats\", jumpBackSeconds)\n)\n\nfunc init() {\n\tregisterCollector(\"cpu\", defaultEnabled, NewCPUCollector)\n}\n\n// NewCPUCollector returns a new Collector exposing kernel/system statistics.\nfunc NewCPUCollector(logger *slog.Logger) (Collector, error) {\n\tpfs, err := procfs.NewFS(*procPath)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to open procfs: %w\", err)\n\t}\n\n\tsfs, err := sysfs.NewFS(*sysPath)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to open sysfs: %w\", err)\n\t}\n\n\tisolcpus, err := sfs.IsolatedCPUs()\n\tif err != nil {\n\t\tif !os.IsNotExist(err) {\n\t\t\treturn nil, fmt.Errorf(\"unable to get isolated cpus: %w\", err)\n\t\t}\n\t\tlogger.Debug(\"couldn't open isolated file\", \"error\", err)\n\t}\n\n\tc := &cpuCollector{\n\t\tprocfs: pfs,\n\t\tsysfs:  sfs,","sourceCodeStart":59,"sourceCodeEnd":95,"githubUrl":"https://github.com/prometheus/node_exporter/blob/17ddd77c59ba27e1508e9f7894b1e55b44d6aed3/collector/cpu_linux.go#L59-L95","documentation":"NewCPUCollector initializes a procfs handle at --path.procfs to read /proc statistics and returns this wrapped error when the filesystem cannot be opened. Because it happens in the constructor, the cpu collector fails to register at startup rather than failing later at scrape time.","triggerScenarios":"procfs.NewFS(*procPath) errors during node_exporter startup: the path does not exist, is not a proc filesystem, or is unreadable.","commonSituations":"Incorrect --path.procfs in containers (host proc mounted at /host/proc); running the Linux build on a system without /proc; chroot/test environments lacking a proc mount.","solutions":["Set --path.procfs to the actual proc mount (e.g. /host/proc in containers)","Confirm /proc is mounted and readable by the exporter user","On non-Linux platforms use the platform-appropriate build instead"],"exampleFix":"// before\npfs, err := procfs.NewFS(*procPath) // procPath=/proc absent\n// after\nnode_exporter --path.procfs=/host/proc","handlingStrategy":"validation","validationCode":"// Go: ensure proc path is mounted and readable before startup\nif _, err := os.Stat(filepath.Join(*procPath, \"stat\")); err != nil {\n    log.Fatal(fmt.Sprintf(\"--path.procfs %s unusable: %v\", *procPath, err))\n}","typeGuard":null,"tryCatchPattern":"if _, err := NewCPUCollector(logger); err != nil {\n    if strings.Contains(err.Error(), \"failed to open procfs\") {\n        return fmt.Errorf(\"fix --path.procfs (default /proc): %w\", err)\n    }\n    return err\n}","preventionTips":["In containers always bind-mount /proc and pass --path.procfs accordingly","Validate flags in your systemd unit/Kubernetes args","Use the OS-appropriate exporter build"],"tags":["procfs","cpu","linux"],"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"}