prometheus/node_exporter · error
couldn't get swap information
Error message
couldn't get swap information: %w
What it means
Update wrapped a failure from getSwapInfo (itself a procfs /proc/swaps read/parse failure) while gathering swap metrics. The whole swap scrape fails for the cycle; the root cause is in the underlying /proc/swaps access.
Solutions
- Check /proc/swaps readability and format as for the underlying error.
- Retry the scrape; transient read failures clear on the next cycle.
- Disable the swap collector if the host has no swap support in its kernel.
Defensive patterns
Strategy: retry
When it happens
Trigger: Thrown at collector/swap_linux.go:81 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/aa9fcf69ff7e3e55.
Report an issue: GitHub.
Appendix: source
Thrown at collector/swap_linux.go:81
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)
}
for _, swap := range swaps {
swapLabelValues := []string{swap.Device, swap.Type}
// Export swap size in bytes
ch <- prometheus.MustNewConstMetric(
prometheus.NewDesc(
prometheus.BuildFQName(namespace, swapSubsystem, "size_bytes"),
"Swap device size in bytes.",
[]string{"device", "swap_type"}, nil,
),
prometheus.GaugeValue,
// Size is provided in kbytes (not bytes), translate to bytes
// see https://github.com/torvalds/linux/blob/fd94619c43360eb44d28bd3ef326a4f85c600a07/mm/swapfile.c#L3079-L3080
float64(swap.Size*1024),
swapLabelValues...,
)View on GitHub (pinned to 17ddd77c59)