{"record":{"id":"618df4953b0d7d26","repo":"prometheus/node_exporter","slug":"failed-to-get-memory-info-w","errorCode":null,"errorMessage":"failed to get memory info: %w","messagePattern":"failed to get memory info: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"collector/meminfo_linux.go","lineNumber":46,"sourceCode":"}\n\n// NewMeminfoCollector returns a new Collector exposing memory stats.\nfunc NewMeminfoCollector(logger *slog.Logger) (Collector, error) {\n\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 &meminfoCollector{\n\t\tlogger: logger,\n\t\tfs:     fs,\n\t}, nil\n}\n\nfunc (c *meminfoCollector) getMemInfo() (map[string]float64, error) {\n\tmeminfo, err := c.fs.Meminfo()\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to get memory info: %w\", err)\n\t}\n\n\tmetrics := make(map[string]float64)\n\n\tif meminfo.ActiveBytes != nil {\n\t\tmetrics[\"Active_bytes\"] = float64(*meminfo.ActiveBytes)\n\t}\n\tif meminfo.ActiveAnonBytes != nil {\n\t\tmetrics[\"Active_anon_bytes\"] = float64(*meminfo.ActiveAnonBytes)\n\t}\n\tif meminfo.ActiveFileBytes != nil {\n\t\tmetrics[\"Active_file_bytes\"] = float64(*meminfo.ActiveFileBytes)\n\t}\n\tif meminfo.AnonHugePagesBytes != nil {\n\t\tmetrics[\"AnonHugePages_bytes\"] = float64(*meminfo.AnonHugePagesBytes)\n\t}\n\tif meminfo.AnonPagesBytes != nil {\n\t\tmetrics[\"AnonPages_bytes\"] = float64(*meminfo.AnonPagesBytes)","sourceCodeStart":28,"sourceCodeEnd":64,"githubUrl":"https://github.com/prometheus/node_exporter/blob/17ddd77c59ba27e1508e9f7894b1e55b44d6aed3/collector/meminfo_linux.go#L28-L64","documentation":"getMemInfo calls fs.Meminfo() to parse /proc/meminfo and wraps any failure in this error. Since the procfs handle was already opened successfully in NewMeminfoCollector, this means the per-call read or parse of the meminfo file failed — e.g. the file is missing at read time, unreadable, or its contents could not be parsed by the procfs library.","triggerScenarios":"c.fs.Meminfo() errors during a scrape: /proc/meminfo disappeared or became unreadable between collector creation and the Update call, the procfs mount is stale/empty (e.g. container with masked /proc paths), or procfs returns a parse error because the kernel's meminfo format is unexpected.","commonSituations":"Containers using LSMs or runtimes that mask /proc/meminfo (e.g. some Kubernetes securityContext setups hiding /proc paths); corrupted or non-Linux procfs emulation (e.g. lxcfs remapping /proc/meminfo) producing unexpected format; host under severe memory/resource pressure causing read failures.","solutions":["Verify /proc/meminfo (or --path.procfs/meminfo) exists and is readable by the exporter process: `cat <procfs>/meminfo`","If using lxcfs or proc-masking, ensure the presented meminfo format is standard or point --path.procfs at the real host procfs","Check LSM/seccomp policies (AppArmor/SELinux/seccomp) that may block reads of /proc/meminfo and adjust the profile","Update the prometheus/procfs dependency if the kernel's meminfo format changed (newer kernels can add fields); check `go get -u github.com/prometheus/procfs`","As a workaround, run with --collector.meminfo disabled if the metric is not needed"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"if f, err := os.Open(filepath.Join(procPath, \"meminfo\")); err != nil {\n    log.Printf(\"/proc/meminfo unreadable: %v\", err)\n} else {\n    f.Close()\n}","typeGuard":null,"tryCatchPattern":"// node_exporter surfaces this per-scrape; monitor scrape errors:\nif err := c.Update(ch); err != nil {\n    c.logger.Error(\"meminfo update failed\", \"err\", err)\n    // alert on node_scrape_collector_success{collector=\"meminfo\"} == 0\n}","preventionTips":["Avoid LSM/seccomp rules that mask or block /proc/meminfo","Watch for lxcfs or similar proc-remapping layers that alter meminfo format","Keep the prometheus/procfs dependency updated for new kernel formats"],"tags":["linux","procfs","memory","scrape"],"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"}