{"record":{"id":"b2bf06c5e69a7c4a","repo":"prometheus/node_exporter","slug":"unable-to-retrieve-limit-number-of-threads-w","errorCode":null,"errorMessage":"unable to retrieve limit number of threads: %w","messagePattern":"unable to retrieve limit number of threads: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"collector/processes_linux.go","lineNumber":94,"sourceCode":"\t\tpidUsed: prometheus.NewDesc(prometheus.BuildFQName(namespace, subsystem, \"pids\"),\n\t\t\t\"Number of PIDs\", nil, nil,\n\t\t),\n\t\tpidMax: prometheus.NewDesc(prometheus.BuildFQName(namespace, subsystem, \"max_processes\"),\n\t\t\t\"Number of max PIDs limit\", nil, nil,\n\t\t),\n\t\tlogger: logger,\n\t}, nil\n}\nfunc (c *processCollector) Update(ch chan<- prometheus.Metric) error {\n\tpids, states, threads, threadStates, err := c.getAllocatedThreads()\n\tif err != nil {\n\t\treturn fmt.Errorf(\"unable to retrieve number of allocated threads: %w\", err)\n\t}\n\n\tch <- prometheus.MustNewConstMetric(c.threadAlloc, prometheus.GaugeValue, float64(threads))\n\tmaxThreads, err := readUintFromFile(procFilePath(\"sys/kernel/threads-max\"))\n\tif err != nil {\n\t\treturn fmt.Errorf(\"unable to retrieve limit number of threads: %w\", err)\n\t}\n\tch <- prometheus.MustNewConstMetric(c.threadLimit, prometheus.GaugeValue, float64(maxThreads))\n\n\tfor state := range states {\n\t\tch <- prometheus.MustNewConstMetric(c.procsState, prometheus.GaugeValue, float64(states[state]), state)\n\t}\n\n\tfor state := range threadStates {\n\t\tch <- prometheus.MustNewConstMetric(c.threadsState, prometheus.GaugeValue, float64(threadStates[state]), state)\n\t}\n\n\tpidM, err := readUintFromFile(procFilePath(\"sys/kernel/pid_max\"))\n\tif err != nil {\n\t\treturn fmt.Errorf(\"unable to retrieve limit number of maximum pids allowed: %w\", err)\n\t}\n\tch <- prometheus.MustNewConstMetric(c.pidUsed, prometheus.GaugeValue, float64(pids))\n\tch <- prometheus.MustNewConstMetric(c.pidMax, prometheus.GaugeValue, float64(pidM))\n","sourceCodeStart":76,"sourceCodeEnd":112,"githubUrl":"https://github.com/prometheus/node_exporter/blob/17ddd77c59ba27e1508e9f7894b1e55b44d6aed3/collector/processes_linux.go#L76-L112","documentation":"After emitting the threads gauge, Update reads /proc/sys/kernel/threads-max with readUintFromFile to expose node_processes_max_threads. This error means that file could not be read or parsed as an unsigned integer, so the threads-limit metric could not be produced.","triggerScenarios":"readUintFromFile(procFilePath(\"sys/kernel/threads-max\")) returns an error during a scrape — the file is missing, unreadable, or its content is not a plain integer.","commonSituations":"Hardened/container environments where /proc/sys/kernel is masked or read-restricted; unusual kernels or security frameworks (e.g. some LSMs) that restrict access to proc sysctls for non-root users.","solutions":["Verify the file is readable: cat /proc/sys/kernel/threads-max as the user running node_exporter.","If a container runtime masks /proc/sys, unmask /proc/sys/kernel/threads-max in the container spec.","Run the exporter with sufficient privileges (root or a capability/appropriate group) to read proc sysctls.","If the metric is not needed and the environment cannot be changed, upgrade node_exporter or file an issue — there is no flag to skip only this metric."],"exampleFix":"// before\n// running as unprivileged user with hidepid/masked sysctls\n// after\n// grant read access or run exporter as root\ndocker run --user root --pid=host quay.io/prometheus/node-exporter ...","handlingStrategy":"validation","validationCode":"// before scraping, as the exporter user\nif _, err := os.ReadFile(\"/proc/sys/kernel/threads-max\"); err != nil {\n    log.Printf(\"threads-max sysctl unreadable: %v\", err)\n}","typeGuard":null,"tryCatchPattern":"if err := c.Update(ch); err != nil {\n    if strings.Contains(err.Error(), \"limit number of threads\") {\n        log.Printf(\"threads-max unavailable in this environment: %v\", err)\n        // degrade: keep other process metrics, drop node_processes_max_threads\n    }\n}","preventionTips":["Ensure the exporter user can read /proc/sys/kernel/threads-max.","Unmask /proc/sys/kernel in container specs that mask proc sysctls.","Test the exporter's scrape under the exact production user, not just root.","Watch for hardened images (LSMs, read-only proc) that hide sysctls."],"tags":["linux","procfs","sysctl","threads","node-exporter"],"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"}