prometheus/node_exporter · error
failed to retrieve bcachefs stats
Error message
failed to retrieve bcachefs stats: %w
What it means
bcachefsCollector.Update wraps errors from c.fs.Stats() in "failed to retrieve bcachefs stats" unless the error is a NotExist (which degrades to ErrNoData). It means the bcachefs sysfs tree was reachable but reading the statistics failed, or the path vanished between construction and scrape. No bcachefs metrics are emitted for the failed scrape.
Solutions
- Verify the bcachefs filesystem is still mounted and /sys/fs/bcachefs is populated (ls /sys/fs/bcachefs)
- Check dmesg for bcachefs errors and remount the filesystem if it was unmounted or went offline
- Confirm the exporter user can read all files under /sys/fs/bcachefs
- Accept ErrNoData behavior: if the path simply does not exist, the collector logs a debug and reports no data rather than erroring
Example fix
// before
stats, err := c.fs.Stats()
log.Fatal(err)
// after
if err != nil {
var pathErr *os.PathError
if errors.As(err, &pathErr) && os.IsNotExist(pathErr) {
return ErrNoData
}
return err
} Defensive patterns
Strategy: try-catch
Validate before calling
if _, err := os.Stat("/sys/fs/bcachefs"); os.IsNotExist(err) { /* expect ErrNoData, skip */ } Try / catch
err := collector.Update(ch)
if err != nil {
if errors.Is(err, collector.ErrNoData) {
return nil // no bcachefs fs present; benign
}
return err
} Prevention
- Keep bcachefs filesystems mounted during scrape intervals
- Audit permissions on /sys/fs/bcachefs after security policy changes
- Track kernel upgrades for bcachefs attribute changes
- Treat ErrNoData as benign rather than alerting
When it happens
Trigger: Mid-scrape unmount/removal of a bcachefs filesystem causing sysfs entries to disappear with an error other than ENOENT, permission changes on /sys/fs/bcachefs files, or I/O failures reading sysfs attributes during the walk.
Common situations: Unmounting a bcachefs volume while node_exporter scrapes; containers with restricted sysfs visibility; kernels where bcachefs attribute layout differs from what the procfs package expects.
Understand the failure class
Background: "failed to read file", EACCES, ENOENT and "could not read <path>" errors: when a program can't read a file from disk — this error's family across 49 libraries.
Related errors
- failed to retrieve bcache stats
- failed to open sysfs
- failed to retrieve Btrfs stats from procfs
- failed to scan DM-multipath devices
- couldn't get NUMA meminfo
AI-assisted analysis of prometheus/node_exporter@17ddd77c59 (2026-09-07).
Data as JSON: /api/errors/ba4bdbc5323af243.
Report an issue: GitHub.
Appendix: source
Thrown at collector/bcachefs_linux.go:141
if err != nil {
return nil, fmt.Errorf("failed to open sysfs: %w", err)
}
return &bcachefsCollector{
fs: fs,
logger: logger,
}, nil
}
// Update retrieves and exports bcachefs statistics.
func (c *bcachefsCollector) Update(ch chan<- prometheus.Metric) error {
stats, err := c.fs.Stats()
if err != nil {
if os.IsNotExist(err) {
c.logger.Debug("bcachefs sysfs path does not exist", "path", sysFilePath("fs/bcachefs"))
return ErrNoData
}
return fmt.Errorf("failed to retrieve bcachefs stats: %w", err)
}
if len(stats) == 0 {
return ErrNoData
}
for _, s := range stats {
uuid := s.UUID
ch <- prometheus.MustNewConstMetric(
bcachefsInfoDesc,
prometheus.GaugeValue,
1,
uuid,
)
ch <- prometheus.MustNewConstMetric(
bcachefsBtreeCacheSizeBytes,View on GitHub (pinned to 17ddd77c59)