{"record":{"id":"f494e316105070ce","repo":"prometheus/node_exporter","slug":"couldn-t-get-netstats-w","errorCode":null,"errorMessage":"couldn't get netstats: %w","messagePattern":"couldn't get netstats: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"collector/netdev_common.go","lineNumber":112,"sourceCode":"\tc.metricDescsMutex.Lock()\n\tdefer c.metricDescsMutex.Unlock()\n\n\tif _, ok := c.metricDescs[key]; !ok {\n\t\tc.metricDescs[key] = prometheus.NewDesc(\n\t\t\tprometheus.BuildFQName(namespace, c.subsystem, key+\"_total\"),\n\t\t\tfmt.Sprintf(\"Network device statistic %s.\", key),\n\t\t\tlabels,\n\t\t\tnil,\n\t\t)\n\t}\n\n\treturn c.metricDescs[key]\n}\n\nfunc (c *netDevCollector) Update(ch chan<- prometheus.Metric) error {\n\tnetDev, err := getNetDevStats(&c.deviceFilter, c.logger)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"couldn't get netstats: %w\", err)\n\t}\n\n\tnetDevLabels, err := getNetDevLabels()\n\tif err != nil {\n\t\treturn fmt.Errorf(\"couldn't get netdev labels: %w\", err)\n\t}\n\n\tfor dev, devStats := range netDev {\n\t\tif !*netdevDetailedMetrics {\n\t\t\tlegacy(devStats)\n\t\t}\n\n\t\tlabels := []string{\"device\"}\n\t\tlabelValues := []string{dev}\n\t\tif devLabels, exists := netDevLabels[dev]; exists {\n\t\t\tfor labelName, labelValue := range devLabels {\n\t\t\t\tlabels = append(labels, labelName)\n\t\t\t\tlabelValues = append(labelValues, labelValue)","sourceCodeStart":94,"sourceCodeEnd":130,"githubUrl":"https://github.com/prometheus/node_exporter/blob/17ddd77c59ba27e1508e9f7894b1e55b44d6aed3/collector/netdev_common.go#L94-L130","documentation":"The netdev collector wraps any error from getNetDevStats() — the platform-specific function that gathers per-interface RX/TX counters (from /proc/net/dev on Linux, net.Interfaces + IOKit/sysctl on darwin, etc.) — as 'couldn't get netstats'. Because this is the first step of netDevCollector.Update, the whole node_network_* metric set is dropped for that scrape when it fails.","triggerScenarios":"getNetDevStats(&c.deviceFilter, c.logger) returns error — on Linux this means procfs open or /proc/net/dev parse failure (see procNetDevStats); on darwin a net.Interfaces() failure; the error text is always this wrapper, so look at %w for the cause.","commonSituations":"--path.procfs pointing at a wrong or unmounted path; container missing /proc/net/dev; /proc mounted with hidepid restrictions; on darwin, network stack initialization failures in sandboxed/test environments.","solutions":["Read the wrapped inner error in the log line to identify the platform-level cause.","Verify the procfs mount path matches the --path.procfs flag (default /proc) and that /proc/net/dev is readable: cat /proc/net/dev.","In containers, mount /proc (or use the host PID namespace pattern used by the official node-exporter manifests).","Check hidepid mount options on /proc; node_exporter needs read access to netdev entries.","Run the collector alone (node_exporter --collector.disable-defaults --collector.netdev) to isolate the failure."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// preflight: netdev source must be readable\nf, err := os.Open(filepath.Join(*procPath, \"net\", \"dev\"))\nif err != nil {\n\treturn fmt.Errorf(\"netdev stats source unreadable: %w\", err)\n}\nf.Close()","typeGuard":null,"tryCatchPattern":"err := collector.Update(ch)\nif err != nil {\n\tif strings.Contains(err.Error(), \"couldn't get netstats\") {\n\t\tlogger.Error(\"netdev scrape failed; inspect wrapped cause\", \"err\", err)\n\t\treturn nil // skip scrape instead of crashing exporter\n\t}\n\treturn err\n}","preventionTips":["Verify --path.procfs matches the actual procfs mount","Monitor the `node_scrape_collector_success{collector=\"netdev\"}` metric","Keep /proc mounted and readable (watch hidepid settings)","Pin node_exporter versions against the kernels you run"],"tags":["network","metrics","procfs"],"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"}