{"record":{"id":"642d22236d89f064","repo":"prometheus/node_exporter","slug":"could-not-get-sysfs-device-info-w","errorCode":null,"errorMessage":"could not get sysfs device info: %w","messagePattern":"could not get sysfs device info: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"collector/netclass_rtnl_linux.go","lineNumber":77,"sourceCode":"\t}\n\n\t// Get most attributes from Netlink\n\tlMsgs, err := c.getNetClassInfoRTNL()\n\tif err != nil {\n\t\treturn fmt.Errorf(\"could not get net class info: %w\", err)\n\t}\n\n\trelevantLinks := make([]rtnetlink.LinkMessage, 0, len(lMsgs))\n\tfor _, msg := range lMsgs {\n\t\tif !c.ignoredDevicesPattern.MatchString(msg.Attributes.Name) {\n\t\t\trelevantLinks = append(relevantLinks, msg)\n\t\t}\n\t}\n\n\t// Read sysfs for attributes that Netlink doesn't expose\n\tsysfsAttrs, err := getSysfsAttributes(relevantLinks)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"could not get sysfs device info: %w\", err)\n\t}\n\n\t// Parse all the info and update metrics\n\tfor _, msg := range relevantLinks {\n\t\tupDesc := prometheus.NewDesc(\n\t\t\tprometheus.BuildFQName(namespace, c.subsystem, \"up\"),\n\t\t\t\"Value is 1 if operstate is 'up', 0 otherwise.\",\n\t\t\t[]string{\"device\"},\n\t\t\tnil,\n\t\t)\n\t\tupValue := 0.0\n\t\tif msg.Attributes.OperationalState == rtnetlink.OperStateUp {\n\t\t\tupValue = 1.0\n\t\t}\n\t\tch <- prometheus.MustNewConstMetric(upDesc, prometheus.GaugeValue, upValue, msg.Attributes.Name)\n\n\t\tinfoDesc := prometheus.NewDesc(\n\t\t\tprometheus.BuildFQName(namespace, c.subsystem, \"info\"),","sourceCodeStart":59,"sourceCodeEnd":95,"githubUrl":"https://github.com/prometheus/node_exporter/blob/17ddd77c59ba27e1508e9f7894b1e55b44d6aed3/collector/netclass_rtnl_linux.go#L59-L95","documentation":"For attributes the kernel does not expose over netlink (speed, duplex, MTU details, address info), the netclass collector reads per-device files under /sys/class/net/<dev>/. getSysfsAttributes() returns an error if reading/walking those sysfs directories fails, and Update aborts with 'could not get sysfs device info'.","triggerScenarios":"getSysfsAttributes(relevantLinks) returns an error: /sys is not mounted, /sys/class/net/<iface> entries are unreadable (permissions), or an I/O error occurs while reading device attribute files (e.g. device hot-unplugged mid-scan).","commonSituations":"Containers launched without /sys mounted read-write or read-only (common in minimal Docker configs missing --volume /sys:/sys:ro); host /sys hidden by LSM policies; NICs removed between the rtnetlink dump and the sysfs read (race in virtualized environments).","solutions":["Mount /sys into the container: docker run -v /sys:/sys:ro ... (or equivalent bind mount in Kubernetes hostPath).","Verify ls /sys/class/net works and files like /sys/class/net/eth0/speed are readable by the exporter user.","Re-check whether the error is a race with device removal; if so, a node_exporter upgrade may make per-device sysfs failures non-fatal.","Inspect the wrapped error to see which path/syscall failed; ensure the exporter runs as a user with read access to sysfs.","Confirm the host, not a Docker-in-Docker inner container, owns the /sys being read."],"exampleFix":"// docker run before (sysfs missing -> collector fails)\ndocker run prom/node-exporter\n// after\ndocker run -v /proc:/host/proc:ro -v /sys:/host/sys:ro --net=host --privileged prom/node-exporter","handlingStrategy":"validation","validationCode":"// preflight: sysfs must expose per-device attribute dirs\nif _, err := os.Stat(\"/sys/class/net\"); err != nil {\n\treturn fmt.Errorf(\"sysfs not available: %w\", err)\n}\nentries, _ := os.ReadDir(\"/sys/class/net\")\nfor _, e := range entries {\n\tif _, err := os.Stat(filepath.Join(\"/sys/class/net\", e.Name(), \"speed\")); err != nil {\n\t\t// that device's sysfs attrs will be missing\n\t}\n}","typeGuard":null,"tryCatchPattern":"if err := collector.Update(ch); err != nil {\n\tvar perr *fs.PathError\n\tif errors.As(err, &perr) && strings.Contains(err.Error(), \"sysfs\") {\n\t\tlogger.Warn(\"sysfs unreadable; check container mounts\", \"path\", perr.Path)\n\t}\n}","preventionTips":["Always bind-mount /sys:ro when running node_exporter in containers","Pass --path.sysfs matching the mount point","Run exporter as a user with read access to /sys/class/net/*","Alert on missing /sys/class/net rather than waiting for scrape errors"],"tags":["linux","sysfs","network"],"backgroundTag":"file-read-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"}