{"record":{"id":"d35d54fef1d68d3a","repo":"prometheus/node_exporter","slug":"couldn-t-get-entropy-avail","errorCode":null,"errorMessage":"couldn't get entropy_avail","messagePattern":"couldn't get entropy_avail","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"collector/entropy_linux.go","lineNumber":68,"sourceCode":"\tfs, err := procfs.NewFS(*procPath)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to open procfs: %w\", err)\n\t}\n\n\treturn &entropyCollector{\n\t\tfs:     fs,\n\t\tlogger: logger,\n\t}, nil\n}\n\nfunc (c *entropyCollector) Update(ch chan<- prometheus.Metric) error {\n\tstats, err := c.fs.KernelRandom()\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to get kernel random stats: %w\", err)\n\t}\n\n\tif stats.EntropyAvaliable == nil {\n\t\treturn fmt.Errorf(\"couldn't get entropy_avail\")\n\t}\n\tch <- prometheus.MustNewConstMetric(\n\t\tentropyAvail, prometheus.GaugeValue, float64(*stats.EntropyAvaliable))\n\n\tif stats.PoolSize == nil {\n\t\treturn fmt.Errorf(\"couldn't get entropy poolsize\")\n\t}\n\tch <- prometheus.MustNewConstMetric(\n\t\tentropyPoolSize, prometheus.GaugeValue, float64(*stats.PoolSize))\n\n\treturn nil\n}\n","sourceCodeStart":50,"sourceCodeEnd":81,"githubUrl":"https://github.com/prometheus/node_exporter/blob/17ddd77c59ba27e1508e9f7894b1e55b44d6aed3/collector/entropy_linux.go#L50-L81","documentation":"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.","triggerScenarios":"c.fs.KernelRandom() succeeds but stats.EntropyAvaliable == nil during Update — entropy_avail missing or empty at parse time.","commonSituations":"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.","solutions":["Verify the file exists and has content: `cat /proc/sys/kernel/random/entropy_avail`.","Update the prometheus/procfs dependency to a version matching your kernel's file layout.","Check container /proc mounts and security filters that may hide the file.","Disable the entropy collector on platforms lacking the random sysctls."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"const fs = require('fs');\nconst f = '/proc/sys/kernel/random/entropy_avail';\nif (!fs.existsSync(f) || fs.readFileSync(f, 'utf8').trim() === '') {\n  console.warn('entropy_avail missing/empty — entropy collector will fail with \"couldn\\'t get entropy_avail\"');\n}","typeGuard":null,"tryCatchPattern":"try {\n  await scrapeNodeExporter();\n} catch (e) {\n  if (String(e).includes('couldn\\'t get entropy_avail')) {\n    console.warn('entropy_avail not parsed; update procfs lib/kernel or disable --collector.entropy');\n  } else throw e;\n}","preventionTips":["Check entropy_avail exists and is numeric before enabling the collector.","Keep the prometheus/procfs dependency current in local builds.","Treat procfs parse nil-fields as a platform capability probe, not a transient error."],"tags":["linux","procfs","entropy","nil-guard"],"backgroundTag":"unexpected-api-response-shape","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"}