prometheus/node_exporter · error

failed to open sysfs

Error message

failed to open sysfs: %w

What it means

NewDMICollector wraps any failure from sysfs.NewFS(*sysPath) with "failed to open sysfs". sysfs.NewFS validates that the sysfs mount point exists and is readable, so this error means the configured --path.sysfs root could not be used as an fs.FS. It aborts collector construction, so the DMI collector is never registered.

Solutions

  1. Verify the --path.sysfs flag points to a mounted, readable sysfs (default /sys)
  2. Mount sysfs into the container: docker run -v /sys:/sys:ro
  3. Create or correct the directory and check permissions with ls -ld /sys
  4. If the platform genuinely has no DMI, rely on the ErrNotExist path being handled downstream and fix the path rather than disabling the collector

Example fix

// before
node_exporter --path.sysfs=/mnt/wrong-sys
// after
node_exporter --path.sysfs=/sys
Defensive patterns

Strategy: validation

Validate before calling

if st, err := os.Stat(sysPath); err != nil || !st.IsDir() {
    // sysfs path unusable; fix --path.sysfs before starting
}

Try / catch

c, err := collector.NewDMICollector(logger)
if err != nil {
    if errors.Is(err, os.ErrNotExist) { /* skip DMI collector */ } else { return err }
}

Prevention

When it happens

Trigger: node_exporter started with --path.sysfs pointing at a nonexistent directory, an unreadable path, or a path that is not a directory; sysfs.NewFS returns an error for any reason other than being handed a usable filesystem root.

Common situations: Running node_exporter in a container without /sys mounted; a typo'd or overridden --path.sysfs flag; sysfs bind-mounted read-only into an unusual location; running on a system where /sys is absent.

Understand the failure class

Background: "open() failed", "failed to open file", "cannot create file" — what a file open error means and how to fix it — this error's family across 42 libraries.

Related errors


AI-assisted analysis of prometheus/node_exporter@17ddd77c59 (2026-09-07). Data as JSON: /api/errors/cb3cf29315e48546. Report an issue: GitHub.

Appendix: source

Thrown at collector/dmi.go:42

	"github.com/prometheus/client_golang/prometheus"
	"github.com/prometheus/procfs/sysfs"
)

type dmiCollector struct {
	infoDesc *prometheus.Desc
	values   []string
}

func init() {
	registerCollector("dmi", defaultEnabled, NewDMICollector)
}

// NewDMICollector returns a new Collector exposing DMI information.
func NewDMICollector(logger *slog.Logger) (Collector, error) {
	fs, err := sysfs.NewFS(*sysPath)
	if err != nil {
		return nil, fmt.Errorf("failed to open sysfs: %w", err)
	}

	dmi, err := fs.DMIClass()
	if err != nil {
		if errors.Is(err, os.ErrNotExist) {
			logger.Debug("Platform does not support Desktop Management Interface (DMI) information", "err", err)
			dmi = &sysfs.DMIClass{}
		} else {
			return nil, fmt.Errorf("failed to read Desktop Management Interface (DMI) information: %w", err)
		}
	}

	var labels, values []string
	for label, value := range map[string]*string{
		"bios_date":         dmi.BiosDate,
		"bios_release":      dmi.BiosRelease,
		"bios_vendor":       dmi.BiosVendor,
		"bios_version":      dmi.BiosVersion,

View on GitHub (pinned to 17ddd77c59)