{"record":{"id":"d83304ede331d5f1","repo":"prometheus/node_exporter","slug":"couldn-t-get-proc-swap-information-w","errorCode":null,"errorMessage":"couldn't get proc/swap information: %w","messagePattern":"couldn't get proc/swap information: %w","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"collector/swap_linux.go","lineNumber":65,"sourceCode":"\n\treturn &swapCollector{\n\t\tfs:     fs,\n\t\tlogger: logger,\n\t}, nil\n}\n\ntype SwapsEntry struct {\n\tDevice   string\n\tType     string\n\tPriority int\n\tSize     int\n\tUsed     int\n}\n\nfunc (c *swapCollector) getSwapInfo() ([]SwapsEntry, error) {\n\tswaps, err := c.fs.Swaps()\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"couldn't get proc/swap information: %w\", err)\n\t}\n\n\tmetrics := make([]SwapsEntry, 0, len(swaps))\n\n\tfor _, swap := range swaps {\n\t\tmetrics = append(metrics, SwapsEntry{Device: swap.Filename, Type: swap.Type,\n\t\t\tPriority: swap.Priority, Size: swap.Size, Used: swap.Used})\n\t}\n\n\treturn metrics, nil\n}\n\nfunc (c *swapCollector) Update(ch chan<- prometheus.Metric) error {\n\tswaps, err := c.getSwapInfo()\n\tif err != nil {\n\t\treturn fmt.Errorf(\"couldn't get swap information: %w\", err)\n\t}\n","sourceCodeStart":47,"sourceCodeEnd":83,"githubUrl":"https://github.com/prometheus/node_exporter/blob/17ddd77c59ba27e1508e9f7894b1e55b44d6aed3/collector/swap_linux.go#L47-L83","documentation":"Reading swap entries from procfs failed: c.fs.Swaps() could not open or parse /proc/swaps inside getSwapInfo. This fires when the /proc/swaps file is absent or unreadable, which occurs on systems with swap entirely disabled (no swap devices configured) or in hardened containers where procfs is restricted; the wrapped error carries the procfs cause. The error propagates up through Update, so the swap collector fails that scrape instead of emitting zeroed or partial swap metrics.","triggerScenarios":"Thrown at collector/swap_linux.go:65 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Verify `cat /proc/swaps` works and shows the expected column layout.","Ensure the file is readable by the exporter user.","Retry; transient errors resolve on the next scrape."],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"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"}