prometheus/node_exporter · error
couldn't get proc/swap information
Error message
couldn't get proc/swap information: %w
What it means
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.
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.
Defensive patterns
Strategy: retry
When it happens
Trigger: Thrown at collector/swap_linux.go:65 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of prometheus/node_exporter@17ddd77c59 (2026-09-07).
Data as JSON: /api/errors/d83304ede331d5f1.
Report an issue: GitHub.
Appendix: source
Thrown at collector/swap_linux.go:65
return &swapCollector{
fs: fs,
logger: logger,
}, nil
}
type SwapsEntry struct {
Device string
Type string
Priority int
Size int
Used int
}
func (c *swapCollector) getSwapInfo() ([]SwapsEntry, error) {
swaps, err := c.fs.Swaps()
if err != nil {
return nil, fmt.Errorf("couldn't get proc/swap information: %w", err)
}
metrics := make([]SwapsEntry, 0, len(swaps))
for _, swap := range swaps {
metrics = append(metrics, SwapsEntry{Device: swap.Filename, Type: swap.Type,
Priority: swap.Priority, Size: swap.Size, Used: swap.Used})
}
return metrics, nil
}
func (c *swapCollector) Update(ch chan<- prometheus.Metric) error {
swaps, err := c.getSwapInfo()
if err != nil {
return fmt.Errorf("couldn't get swap information: %w", err)
}
View on GitHub (pinned to 17ddd77c59)