{"record":{"id":"d8f1ad321b33f845","repo":"prometheus/node_exporter","slug":"couldn-t-get-units-w","errorCode":null,"errorMessage":"couldn't get units: %w","messagePattern":"couldn't get units: %w","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"collector/systemd_linux.go","lineNumber":211,"sourceCode":"\t}\n\tch <- prometheus.MustNewConstMetric(\n\t\tc.systemdVersionDesc,\n\t\tprometheus.GaugeValue,\n\t\tsystemdVersion,\n\t\tsystemdVersionFull,\n\t)\n\n\tsystemdVirtualization := c.getSystemdVirtualization(conn)\n\tch <- prometheus.MustNewConstMetric(\n\t\tc.virtualizationDesc,\n\t\tprometheus.GaugeValue,\n\t\t1.0,\n\t\tsystemdVirtualization,\n\t)\n\n\tallUnits, err := c.getAllUnits(conn)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"couldn't get units: %w\", err)\n\t}\n\tc.logger.Debug(\"getAllUnits took\", \"duration_seconds\", time.Since(begin).Seconds())\n\n\tbegin = time.Now()\n\tsummary := summarizeUnits(allUnits)\n\tc.collectSummaryMetrics(ch, summary)\n\tc.logger.Debug(\"collectSummaryMetrics took\", \"duration_seconds\", time.Since(begin).Seconds())\n\n\tbegin = time.Now()\n\tunits := filterUnits(allUnits, c.systemdUnitIncludePattern, c.systemdUnitExcludePattern, c.logger)\n\tc.logger.Debug(\"filterUnits took\", \"duration_seconds\", time.Since(begin).Seconds())\n\n\tvar wg sync.WaitGroup\n\tdefer wg.Wait()\n\n\twg.Go(func() {\n\t\tbegin := time.Now()\n\t\tc.collectUnitStatusMetrics(conn, ch, units)","sourceCodeStart":193,"sourceCodeEnd":229,"githubUrl":"https://github.com/prometheus/node_exporter/blob/17ddd77c59ba27e1508e9f7894b1e55b44d6aed3/collector/systemd_linux.go#L193-L229","documentation":"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.","triggerScenarios":"systemd D-Bus ListUnits call errors: systemd restarting mid-scrape, bus timeout under load, or policy (dbus polkit/SELinux) denying org.freedesktop.systemd1.ListUnits.","commonSituations":"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.","solutions":["Retry the scrape; transient systemd restarts self-resolve","Check dbus/SELinux policy allows the exporter user to call ListUnits","Increase scrape_timeout in the Prometheus scrape config for busy hosts","Confirm systemd is healthy: `systemctl is-system-running`"],"exampleFix":null,"handlingStrategy":"retry","validationCode":"conn, err := dbus.SystemBusPrivate(); if err != nil { /* no bus: don't attempt ListUnits */ }","typeGuard":null,"tryCatchPattern":"if err != nil && strings.Contains(err.Error(), \"couldn't get units\") {\n    // transient: retry with backoff on next scrape; alert only after N consecutive failures\n}","preventionTips":["Set scrape_timeout above systemd bus latency on large hosts (many units)","Allow-list node_exporter in SELinux/dbus policy","Avoid scraping during systemd upgrade/restart windows"],"tags":["linux","systemd","dbus","scrape"],"backgroundTag":"api-request-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"}