prometheus/node_exporter · error

failed to retrieve wifi interfaces

Error message

failed to retrieve wifi interfaces: %w

What it means

node_exporter's wifi collector wraps any error returned by the wifi package's stat.Interfaces() call, which queries the kernel via netlink (NL80211_CMD_GET_INTERFACE) to enumerate wireless interfaces. If the netlink dump fails, the collector aborts the whole scrape and returns this wrapped error, so no wifi metrics are produced for the scrape.

Solutions

  1. Check whether the host actually has wifi interfaces; if not, disable the wifi collector with --collector.wifi so the error stops occurring.
  2. Run node_exporter with sufficient privileges (CAP_NET_ADMIN / not inside a netns that blocks netlink) and re-test.
  3. Verify netlink nl80211 is available: 'ip link' shows wifi devices and the kernel supports CONFIG_CFG80211.
  4. Inspect the underlying wrapped error (%w) in logs to identify whether it is permission, socket, or protocol related.
  5. Update to a recent node_exporter / mdlayher/wifi release in case of a kernel-compat bug.

Example fix

// before
node_exporter --collector.wifi   # fails in container without wifi/netlink
// after
node_exporter --collector.wifi   # or simply omit the flag; wifi is opt-in
# or grant: docker run --cap-add NET_ADMIN ...
Defensive patterns

Strategy: try-catch

Validate before calling

// Go: before enabling, check the host can enumerate wifi interfaces
if _, err := os.ReadDir("/sys/class/net"); err != nil {
    // no network sysfs access; skip enabling the wifi collector
}
// or probe: iw dev must list wireless devices for metrics to exist

Type guard

// Go: inspect the wrapped netlink error before treating it as fatal
var nlErr xerrors.WrappedError
if errors.As(err, &nlErr) && errors.Is(err, os.ErrPermission) {
    // degrade gracefully instead of failing the scrape
}

Try / catch

if err := coll.Update(ch); err != nil {
    if strings.Contains(err.Error(), "failed to retrieve wifi interfaces") {
        logger.Warn("wifi netlink enumeration failed; skipping wifi metrics", "err", err)
        return nil // degrade, don't fail the scrape
    }
    return err
}

Prevention

When it happens

Trigger: stat.Interfaces() returns an error during wifiCollector.Update — e.g. the netlink socket creation or interface dump fails, the process lacks permission to issue NL80211 commands, or the kernel rejects the netlink request.

Common situations: Running node_exporter inside a container without CAP_NET_ADMIN, restricted netlink permissions (SELinux/AppArmor), unusual kernels/network namespaces where the nl80211 family is unavailable, or a wifi driver misbehaving on the netlink query.

Related errors


AI-assisted analysis of prometheus/node_exporter@17ddd77c59 (2026-09-07). Data as JSON: /api/errors/fac66c349066db23. Report an issue: GitHub.

Appendix: source

Thrown at collector/wifi_linux.go:172

	stat, err := newWifiStater(*collectorWifi)
	if err != nil {
		// Cannot access wifi metrics, report no error.
		if errors.Is(err, os.ErrNotExist) {
			c.logger.Debug("wifi collector metrics are not available for this system")
			return ErrNoData
		}
		if errors.Is(err, os.ErrPermission) {
			c.logger.Debug("wifi collector got permission denied when accessing metrics")
			return ErrNoData
		}

		return fmt.Errorf("failed to access wifi data: %w", err)
	}
	defer stat.Close()

	ifis, err := stat.Interfaces()
	if err != nil {
		return fmt.Errorf("failed to retrieve wifi interfaces: %w", err)
	}

	for _, ifi := range ifis {
		// Some virtual devices have no "name" and should be skipped.
		if ifi.Name == "" {
			continue
		}

		c.logger.Debug("probing wifi device with type", "wifi", ifi.Name, "type", ifi.Type)

		ch <- prometheus.MustNewConstMetric(
			wifiInterfaceFrequencyHertz,
			prometheus.GaugeValue,
			mHzToHz(ifi.Frequency),
			ifi.Name,
		)

		// When a statistic is not available for a given interface, package wifi

View on GitHub (pinned to 17ddd77c59)