prometheus/node_exporter · error

couldn't get entropy_avail

Error message

couldn't get entropy_avail

What it means

After a successful KernelRandom() call, the collector guards that stats.EntropyAvaliable (parsed from /proc/sys/kernel/random/entropy_avail) is non-nil. If the procfs package could not populate the field, Update returns this plain error. It signals that the file was absent or unparseable even though the overall read did not hard-fail.

Solutions

  1. Verify the file exists and has content: `cat /proc/sys/kernel/random/entropy_avail`.
  2. Update the prometheus/procfs dependency to a version matching your kernel's file layout.
  3. Check container /proc mounts and security filters that may hide the file.
  4. Disable the entropy collector on platforms lacking the random sysctls.
Defensive patterns

Strategy: try-catch

Validate before calling

const fs = require('fs');
const f = '/proc/sys/kernel/random/entropy_avail';
if (!fs.existsSync(f) || fs.readFileSync(f, 'utf8').trim() === '') {
  console.warn('entropy_avail missing/empty — entropy collector will fail with "couldn\'t get entropy_avail"');
}

Try / catch

try {
  await scrapeNodeExporter();
} catch (e) {
  if (String(e).includes('couldn\'t get entropy_avail')) {
    console.warn('entropy_avail not parsed; update procfs lib/kernel or disable --collector.entropy');
  } else throw e;
}

Prevention

When it happens

Trigger: c.fs.KernelRandom() succeeds but stats.EntropyAvaliable == nil during Update — entropy_avail missing or empty at parse time.

Common situations: Kernel without entropy_avail in /proc/sys/kernel/random; racing reader truncating the file during parse; unusual procfs mounts (lxcfs) hiding the file; procfs library version parsing a different file set.

Understand the failure class

Background: "invalid response format", "malformed payload", "missing data field": when an API returns 200 but the response shape is wrong — this error's family across 23 libraries.

Related errors


AI-assisted analysis of prometheus/node_exporter@17ddd77c59 (2026-09-07). Data as JSON: /api/errors/d35d54fef1d68d3a. Report an issue: GitHub.

Appendix: source

Thrown at collector/entropy_linux.go:68

	fs, err := procfs.NewFS(*procPath)
	if err != nil {
		return nil, fmt.Errorf("failed to open procfs: %w", err)
	}

	return &entropyCollector{
		fs:     fs,
		logger: logger,
	}, nil
}

func (c *entropyCollector) Update(ch chan<- prometheus.Metric) error {
	stats, err := c.fs.KernelRandom()
	if err != nil {
		return fmt.Errorf("failed to get kernel random stats: %w", err)
	}

	if stats.EntropyAvaliable == nil {
		return fmt.Errorf("couldn't get entropy_avail")
	}
	ch <- prometheus.MustNewConstMetric(
		entropyAvail, prometheus.GaugeValue, float64(*stats.EntropyAvaliable))

	if stats.PoolSize == nil {
		return fmt.Errorf("couldn't get entropy poolsize")
	}
	ch <- prometheus.MustNewConstMetric(
		entropyPoolSize, prometheus.GaugeValue, float64(*stats.PoolSize))

	return nil
}

View on GitHub (pinned to 17ddd77c59)