{"record":{"id":"c5f63a2dd90232bb","repo":"prometheus/node_exporter","slug":"failed-to-open-procfs-w-c5f63a","errorCode":null,"errorMessage":"failed to open procfs: %w","messagePattern":"failed to open procfs: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"collector/cgroups_linux.go","lineNumber":54,"sourceCode":"\nvar (\n\tcgroupsCgroups = prometheus.NewDesc(\n\t\tprometheus.BuildFQName(namespace, cgroupsCollectorSubsystem, \"cgroups\"),\n\t\t\"Current cgroup number of the subsystem.\",\n\t\t[]string{\"subsys_name\"}, nil,\n\t)\n\tcgroupsEnabled = prometheus.NewDesc(\n\t\tprometheus.BuildFQName(namespace, cgroupsCollectorSubsystem, \"enabled\"),\n\t\t\"Current cgroup number of the subsystem.\",\n\t\t[]string{\"subsys_name\"}, nil,\n\t)\n)\n\n// NewCgroupSummaryCollector returns a new Collector exposing a summary of cgroups.\nfunc NewCgroupSummaryCollector(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 &cgroupSummaryCollector{\n\t\tfs:     fs,\n\t\tlogger: logger,\n\t}, nil\n}\n\n// Update implements Collector and exposes cgroup statistics.\nfunc (c *cgroupSummaryCollector) Update(ch chan<- prometheus.Metric) error {\n\tcgroupSummarys, err := c.fs.CgroupSummarys()\n\tif err != nil {\n\t\treturn err\n\t}\n\tfor _, cs := range cgroupSummarys {\n\t\tch <- prometheus.MustNewConstMetric(cgroupsCgroups, prometheus.GaugeValue, float64(cs.Cgroups), cs.SubsysName)\n\t\tch <- prometheus.MustNewConstMetric(cgroupsEnabled, prometheus.GaugeValue, float64(cs.Enabled), cs.SubsysName)\n\t}\n\treturn nil","sourceCodeStart":36,"sourceCodeEnd":72,"githubUrl":"https://github.com/prometheus/node_exporter/blob/17ddd77c59ba27e1508e9f7894b1e55b44d6aed3/collector/cgroups_linux.go#L36-L72","documentation":"NewCgroupSummaryCollector wraps errors from procfs.NewFS(*procPath) in \"failed to open procfs\". The collector could not obtain a procfs handle at construction time, so no cgroup summary metrics can be collected. Same root causes as other procfs-opening collectors: /proc missing, misconfigured path, or access denied.","triggerScenarios":"Enabling the cgroups collector where /proc is not mounted, --path.procfs points to an invalid directory, the process lacks permission to access /proc, or in restricted container namespaces.","commonSituations":"Containers without procfs mounted; unit/integration tests using a bogus procPath; hosts with procfs hidepid settings that restrict access; non-Linux environments.","solutions":["Ensure /proc is mounted and readable, and --path.procfs is correct if overridden","Relax hidepid or run the exporter with sufficient privileges if /proc access is restricted","Disable the cgroups collector (--no-collector.cgroups) in environments without procfs","Inspect LSM/seccomp logs for denials on /proc"],"exampleFix":"// before\n collector, err := NewNodeCollector(logger, \"cgroups\")\n// after\n if fi, err := os.Stat(*procPath); err != nil || !fi.IsDir() {\n\tlogger.Warn(\"procfs path invalid; skipping cgroups collector\")\n\treturn nil\n }\n collector, err = NewNodeCollector(logger, \"cgroups\")","handlingStrategy":"fallback","validationCode":"if fi, err := os.Stat(*procPath); err != nil || !fi.IsDir() { /* skip cgroups collector */ }","typeGuard":"func procfsReady(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(\"cgroups collector unavailable\", \"err\", err)\n\tc = nil\n}","preventionTips":["Ensure /proc is mounted and not restricted by hidepid","Use host PID namespace for accurate cgroup visibility in containers","Validate --path.procfs during deployment checks","Disable cgroups collector where procfs is unavailable"],"tags":["linux","procfs","collector-init","cgroups"],"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"}