prometheus/node_exporter · error

failed to access wifi data

Error message

failed to access wifi data: %w

What it means

The wifi collector's Update creates a wifi stat handle via the local wifi library (netlink-based). Errors from establishing that handle — other than os.ErrPermission, which is downgraded to ErrNoData — are wrapped as 'failed to access wifi data: %w'. It means the collector could not begin querying wireless interface information at all.

Solutions

  1. Confirm the host actually has wireless interfaces and cfg80211/nl80211 support (lsmod | grep cfg80211).
  2. Disable the wifi collector on hosts with no wireless hardware.
  3. Run in the host network namespace so netlink queries reach the real kernel.
  4. Check the wrapped error; EPERM is intentionally downgraded to ErrNoData.
Defensive patterns

Strategy: try-catch

Validate before calling

// probe nl80211 availability before enabling wifi collection
// e.g. run: iw list  (or check /sys/class/net/*/wireless exists)
hasWireless := false
ents, _ := os.ReadDir("/sys/class/net")
for _, e := range ents {
    if _, err := os.Stat("/sys/class/net/" + e.Name() + "/wireless"); err == nil {
        hasWireless = true
    }
}
_ = hasWireless

Try / catch

if err := c.Update(ch); err != nil {
    if errors.Is(err, ErrNoData) { return }
    if strings.Contains(err.Error(), "failed to access wifi data") {
        logger.Warn("wifi metrics unavailable", "err", err)
        return
    }
    return err
}

Prevention

When it happens

Trigger: wifiCollector.Update when the wifi stat handle creation fails with non-EPERM errors — typically nl80211/cfg80211 not available in the kernel, or netlink socket creation failing.

Common situations: Running on servers/wired-only hosts without wireless extensions, kernels built without cfg80211/nl80211, containers without access to the host's network netlink namespace, and unprivileged users hitting permission-related paths (those return ErrNoData instead).

Related errors


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

Appendix: source

Thrown at collector/wifi_linux.go:166

	return &wifiCollector{
		logger: logger,
	}, nil
}

func (c *wifiCollector) Update(ch chan<- prometheus.Metric) error {
	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,

View on GitHub (pinned to 17ddd77c59)