prometheus/node_exporter · error

couldn't get units

Error message

couldn't get units: %w

What it means

getAllUnits (ListUnits over D-Bus) failed after a successful connection, so Update cannot enumerate systemd units and returns this wrapped error. Failures here come from the D-Bus call itself rather than connection setup.

Solutions

  1. Retry the scrape; transient systemd restarts self-resolve
  2. Check dbus/SELinux policy allows the exporter user to call ListUnits
  3. Increase scrape_timeout in the Prometheus scrape config for busy hosts
  4. Confirm systemd is healthy: `systemctl is-system-running`
Defensive patterns

Strategy: retry

Validate before calling

conn, err := dbus.SystemBusPrivate(); if err != nil { /* no bus: don't attempt ListUnits */ }

Try / catch

if err != nil && strings.Contains(err.Error(), "couldn't get units") {
    // transient: retry with backoff on next scrape; alert only after N consecutive failures
}

Prevention

When it happens

Trigger: systemd D-Bus ListUnits call errors: systemd restarting mid-scrape, bus timeout under load, or policy (dbus polkit/SELinux) denying org.freedesktop.systemd1.ListUnits.

Common situations: Heavily loaded hosts where the systemd bus times out; SELinux/MAC policies blocking node_exporter's D-Bus calls; systemd being upgraded/restarted during collection.

Understand the failure class

Background: "API request failed": what wrapped HTTP errors from external APIs mean and how to find the real cause — this error's family across 29 libraries.

Related errors


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

Appendix: source

Thrown at collector/systemd_linux.go:211

	}
	ch <- prometheus.MustNewConstMetric(
		c.systemdVersionDesc,
		prometheus.GaugeValue,
		systemdVersion,
		systemdVersionFull,
	)

	systemdVirtualization := c.getSystemdVirtualization(conn)
	ch <- prometheus.MustNewConstMetric(
		c.virtualizationDesc,
		prometheus.GaugeValue,
		1.0,
		systemdVirtualization,
	)

	allUnits, err := c.getAllUnits(conn)
	if err != nil {
		return fmt.Errorf("couldn't get units: %w", err)
	}
	c.logger.Debug("getAllUnits took", "duration_seconds", time.Since(begin).Seconds())

	begin = time.Now()
	summary := summarizeUnits(allUnits)
	c.collectSummaryMetrics(ch, summary)
	c.logger.Debug("collectSummaryMetrics took", "duration_seconds", time.Since(begin).Seconds())

	begin = time.Now()
	units := filterUnits(allUnits, c.systemdUnitIncludePattern, c.systemdUnitExcludePattern, c.logger)
	c.logger.Debug("filterUnits took", "duration_seconds", time.Since(begin).Seconds())

	var wg sync.WaitGroup
	defer wg.Wait()

	wg.Go(func() {
		begin := time.Now()
		c.collectUnitStatusMetrics(conn, ch, units)

View on GitHub (pinned to 17ddd77c59)