{"record":{"id":"6effc8bd6276cdb4","repo":"prometheus/node_exporter","slug":"failed-to-open-sysfs-w-6effc8","errorCode":null,"errorMessage":"failed to open sysfs: %w","messagePattern":"failed to open sysfs: %w","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"collector/tapestats_linux.go","lineNumber":60,"sourceCode":"\twritesCompletedTotal  *prometheus.Desc\n\twriteTimeSeconds      *prometheus.Desc\n\tresidualTotal         *prometheus.Desc\n\tfs                    sysfs.FS\n\tlogger                *slog.Logger\n}\n\nfunc init() {\n\tregisterCollector(\"tapestats\", defaultEnabled, NewTapestatsCollector)\n}\n\n// NewTapestatsCollector returns a new Collector exposing tape device stats.\n// Docs from https://www.kernel.org/doc/html/latest/scsi/st.html#sysfs-and-statistics-for-tape-devices\nfunc NewTapestatsCollector(logger *slog.Logger) (Collector, error) {\n\tvar tapeLabelNames = []string{\"device\"}\n\n\tfs, err := sysfs.NewFS(*sysPath)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to open sysfs: %w\", err)\n\t}\n\n\ttapeSubsystem := \"tape\"\n\n\treturn &tapestatsCollector{\n\t\tignoredDevicesPattern: regexp.MustCompile(*ignoredTapeDevices),\n\n\t\tioNow: prometheus.NewDesc(\n\t\t\tprometheus.BuildFQName(namespace, tapeSubsystem, \"io_now\"),\n\t\t\t\"The number of I/Os currently outstanding to this device.\",\n\t\t\ttapeLabelNames, nil,\n\t\t),\n\t\tioTimeSeconds: prometheus.NewDesc(\n\t\t\tprometheus.BuildFQName(namespace, tapeSubsystem, \"io_time_seconds_total\"),\n\t\t\t\"The amount of time spent waiting for all I/O to complete (including read and write). This includes tape movement commands such as seeking between file or set marks and implicit tape movement such as when rewind on close tape devices are used.\",\n\t\t\ttapeLabelNames, nil,\n\t\t),\n\t\tothersCompletedTotal: prometheus.NewDesc(","sourceCodeStart":42,"sourceCodeEnd":78,"githubUrl":"https://github.com/prometheus/node_exporter/blob/17ddd77c59ba27e1508e9f7894b1e55b44d6aed3/collector/tapestats_linux.go#L42-L78","documentation":"NewTapestatsCollector constructs its collector by opening a sysfs filesystem handle via sysfs.NewFS(*sysPath) (default /sys). If that path cannot be opened/read as a filesystem, the collector cannot be created and construction fails with this wrapped error. This is a startup-time failure, not a scrape-time one.","triggerScenarios":"The --path.sysfs flag points at a nonexistent or unreadable directory, or sysfs.NewFS cannot stat/access the given root path at collector construction time.","commonSituations":"Typo in --path.sysfs when testing; running node_exporter in a minimal container where /sys is not mounted; chroot/jail environments without sysfs mounted; permission restrictions from seccomp/AppArmor blocking /sys access.","solutions":["Check the --path.sysfs value points at a mounted sysfs directory (default /sys)","Mount sysfs if missing: on hosts it is normally there; in containers pass --path.sysfs=/host/sys with -v /sys:/host/sys:ro","Test access manually: ls /sys/class/scsi_tape as the user node_exporter runs as","If tapestats is not needed, disable it with --collector.tapestats to avoid constructing the collector"],"exampleFix":"// before: container without sysfs\ndocker run prom/node-exporter --collector.tapestats\n// after\ndocker run -v /sys:/host/sys:ro prom/node-exporter --path.sysfs=/host/sys","handlingStrategy":"validation","validationCode":"if fi, err := os.Stat(*sysPath); err != nil || !fi.IsDir() {\n    // fix --path.sysfs before enabling tapestats\n}","typeGuard":null,"tryCatchPattern":"coll, err := NewTapestatsCollector(logger)\nif err != nil {\n    logger.Warn(\"tapestats disabled\", \"err\", err)\n    coll = nil\n}","preventionTips":["Keep the default --path.sysfs=/sys unless you have a specific reason","In containers, bind-mount /sys read-only and set --path.sysfs accordingly","Only enable --collector.tapestats on hosts with SCSI tape devices","Check filesystem mounts before deploying to minimal images"],"tags":["sysfs","linux","tape","collector-init"],"backgroundTag":"file-not-found","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"}