{"record":{"id":"ea22593b86e39362","repo":"prometheus/node_exporter","slug":"failed-to-open-procfs-w-ea2259","errorCode":null,"errorMessage":"failed to open procfs: %w","messagePattern":"failed to open procfs: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"collector/buddyinfo.go","lineNumber":52,"sourceCode":"}\n\nfunc init() {\n\tregisterCollector(\"buddyinfo\", defaultDisabled, NewBuddyinfoCollector)\n}\n\nvar (\n\tbuddyinfoBlocks = prometheus.NewDesc(\n\t\tprometheus.BuildFQName(namespace, buddyInfoSubsystem, \"blocks\"),\n\t\t\"Count of free blocks according to size.\",\n\t\t[]string{\"node\", \"zone\", \"size\"}, nil,\n\t)\n)\n\n// NewBuddyinfoCollector returns a new Collector exposing buddyinfo stats.\nfunc NewBuddyinfoCollector(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\treturn &buddyinfoCollector{fs, logger}, nil\n}\n\n// Update calls (*buddyinfoCollector).getBuddyInfo to get the platform specific\n// buddyinfo metrics.\nfunc (c *buddyinfoCollector) Update(ch chan<- prometheus.Metric) error {\n\tbuddyInfo, err := c.fs.BuddyInfo()\n\tif err != nil {\n\t\treturn fmt.Errorf(\"couldn't get buddyinfo: %w\", err)\n\t}\n\n\tc.logger.Debug(\"Set node_buddy\", \"buddyInfo\", buddyInfo)\n\tfor _, entry := range buddyInfo {\n\t\tfor size, value := range entry.Sizes {\n\t\t\tch <- prometheus.MustNewConstMetric(\n\t\t\t\tbuddyinfoBlocks,\n\t\t\t\tprometheus.GaugeValue, value,","sourceCodeStart":34,"sourceCodeEnd":70,"githubUrl":"https://github.com/prometheus/node_exporter/blob/17ddd77c59ba27e1508e9f7894b1e55b44d6aed3/collector/buddyinfo.go#L34-L70","documentation":"NewBuddyinfoCollector wraps errors from procfs.NewFS(*procPath) in \"failed to open procfs\". The /proc filesystem handle could not be created, so the buddyinfo collector cannot be constructed. This typically indicates /proc is missing, not mounted, or the --path.procfs override is invalid.","triggerScenarios":"Enabling the buddyinfo collector on a system without /proc mounted, a wrong --path.procfs value, insufficient permissions to stat/access /proc, or in containers/chroots where procfs is not mounted.","commonSituations":"Minimal Docker images or sandboxes without procfs; node_exporter running with a custom --path.procfs for testing that points at a nonexistent directory; non-Linux platforms where procfs semantics don't apply.","solutions":["Verify /proc is mounted (mount | grep proc) and readable by the exporter","Correct the --path.procfs flag if a custom path was supplied","Disable the buddyinfo collector (--no-collector.buddyinfo) in environments without procfs","Check LSM denials if /proc access is blocked by security policy"],"exampleFix":"// before\n c, err := NewNodeCollector(logger, \"buddyinfo\") // fails when /proc missing\n// after\n if _, err := os.Stat(*procPath); err != nil {\n\tlogger.Warn(\"procfs unavailable; skipping buddyinfo collector\")\n\treturn nil\n }\n c, err = NewNodeCollector(logger, \"buddyinfo\")","handlingStrategy":"fallback","validationCode":"if fi, err := os.Stat(*procPath); err != nil || !fi.IsDir() { /* skip buddyinfo collector */ }","typeGuard":"func procfsAvailable(path string) bool { fi, err := os.Stat(path); return err == nil && fi.IsDir() }","tryCatchPattern":"c, err := collector.NewNodeCollector(logger)\nif err != nil {\n\tlogger.Warn(\"buddyinfo collector unavailable\", \"err\", err)\n\tc = nil\n}","preventionTips":["Mount /proc in all containers running node_exporter","Verify --path.procfs before rollout","Check hidepid mount options don't block exporter access","Disable buddyinfo on platforms lacking /proc/buddyinfo"],"tags":["linux","procfs","collector-init","buddyinfo"],"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"}