{"record":{"id":"6b5dc922aa97fca5","repo":"prometheus/node_exporter","slug":"failed-to-retrieve-rapl-stats-w","errorCode":null,"errorMessage":"failed to retrieve rapl stats: %w","messagePattern":"failed to retrieve rapl stats: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"collector/rapl_linux.go","lineNumber":82,"sourceCode":"\t\tjoulesMetricDesc: joulesMetricDesc,\n\t}\n\treturn &collector, nil\n}\n\n// Update implements Collector and exposes RAPL related metrics.\nfunc (c *raplCollector) Update(ch chan<- prometheus.Metric) error {\n\t// nil zones are fine when platform doesn't have powercap files present.\n\tzones, err := sysfs.GetRaplZones(c.fs)\n\tif err != nil {\n\t\tif errors.Is(err, os.ErrNotExist) {\n\t\t\tc.logger.Debug(\"Platform doesn't have powercap files present\", \"err\", err)\n\t\t\treturn ErrNoData\n\t\t}\n\t\tif errors.Is(err, os.ErrPermission) {\n\t\t\tc.logger.Debug(\"Can't access powercap files\", \"err\", err)\n\t\t\treturn ErrNoData\n\t\t}\n\t\treturn fmt.Errorf(\"failed to retrieve rapl stats: %w\", err)\n\t}\n\n\tfor _, rz := range zones {\n\t\tmicroJoules, err := rz.GetEnergyMicrojoules()\n\t\tif err != nil {\n\t\t\tif errors.Is(err, os.ErrPermission) {\n\t\t\t\tc.logger.Debug(\"Can't access energy_uj file\", \"zone\", rz, \"err\", err)\n\t\t\t\treturn ErrNoData\n\t\t\t}\n\t\t\treturn err\n\t\t}\n\n\t\tjoules := float64(microJoules) / 1000000.0\n\n\t\tif *raplZoneLabel {\n\t\t\tch <- c.joulesMetricWithZoneLabel(rz, joules)\n\t\t} else {\n\t\t\tch <- c.joulesMetric(rz, joules)","sourceCodeStart":64,"sourceCodeEnd":100,"githubUrl":"https://github.com/prometheus/node_exporter/blob/17ddd77c59ba27e1508e9f7894b1e55b44d6aed3/collector/rapl_linux.go#L64-L100","documentation":"The RAPL power collector wraps any non-permission error from reading powercap zones (procfs powercap API) with 'failed to retrieve rapl stats'. Missing powercap and permission errors are downgraded to ErrNoData or a debug log, so this error means a genuine failure enumerating or reading the Intel RAPL powercap interface outside those tolerated cases.","triggerScenarios":"powercap zone initialization returning an error other than os.ErrNotExist/os.ErrPermission during Update, e.g. malformed /sys/class/powercap contents or I/O errors reading energy files.","commonSituations":"Containers with partial /sys/class/powercap visibility; virtualized hosts exposing a broken powercap tree; kernels with partial or faulty intel_rapl support.","solutions":["Inspect /sys/class/powercap for intact intel-rapl:* entries with readable name/energy_uj files","If RAPL is unusable on this host, disable the rapl collector instead of scraping it","Check dmesg for intel_rapl/powercap errors and update the kernel or run on bare metal","Verify the container runtime is not masking parts of /sys/class/powercap"],"exampleFix":"// before (host without usable RAPL)\nnode_exporter --collector.rapl\n// after\nnode_exporter --collector.rapl=false  # or omit --collector.rapl when not using --collector.disable-defaults","handlingStrategy":"try-catch","validationCode":"// caller-side pre-check before enabling the collector\nif entries, err := os.ReadDir(\"/sys/class/powercap\"); err != nil || len(entries) == 0 {\n\t// RAPL unavailable; do not enable --collector.rapl\n}","typeGuard":"func raplAvailable() bool {\n\t_, err := os.Stat(\"/sys/class/powercap/intel-rapl:0\")\n\treturn err == nil\n}","tryCatchPattern":"if err := collector.Update(ch); err != nil {\n\tif strings.Contains(err.Error(), \"failed to retrieve rapl stats\") {\n\t\tlogger.Warn(\"RAPL unavailable on this host; power metrics skipped\", \"err\", err)\n\t} else {\n\t\treturn err\n\t}\n}","preventionTips":["Only enable the rapl collector on bare metal or hosts that expose /sys/class/powercap","Check dmesg for intel_rapl initialization errors when provisioning","Treat missing/permission-denied powercap as expected: the collector already returns ErrNoData for those"],"tags":["rapl","power","sysfs","linux"],"backgroundTag":"file-read-failed","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"}