{"record":{"id":"39433bf0c7f27202","repo":"prometheus/node_exporter","slug":"couldn-t-get-system-state-w","errorCode":null,"errorMessage":"couldn't get system state: %w","messagePattern":"couldn't get system state: %w","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"collector/systemd_linux.go","lineNumber":428,"sourceCode":"\t\t}\n\n\t\tch <- prometheus.MustNewConstMetric(\n\t\t\tc.timerLastTriggerDesc, prometheus.GaugeValue,\n\t\t\tfloat64(lastTriggerValue.Value.Value().(uint64))/1e6, unit.Name)\n\t}\n}\n\nfunc (c *systemdCollector) collectSummaryMetrics(ch chan<- prometheus.Metric, summary map[string]float64) {\n\tfor stateName, count := range summary {\n\t\tch <- prometheus.MustNewConstMetric(\n\t\t\tc.summaryDesc, prometheus.GaugeValue, count, stateName)\n\t}\n}\n\nfunc (c *systemdCollector) collectSystemState(conn *dbus.Conn, ch chan<- prometheus.Metric) error {\n\tsystemState, err := conn.GetManagerProperty(\"SystemState\")\n\tif err != nil {\n\t\treturn fmt.Errorf(\"couldn't get system state: %w\", err)\n\t}\n\tisSystemRunning := 0.0\n\tif systemState == `\"running\"` {\n\t\tisSystemRunning = 1.0\n\t}\n\tch <- prometheus.MustNewConstMetric(c.systemRunningDesc, prometheus.GaugeValue, isSystemRunning)\n\treturn nil\n}\n\nfunc newSystemdDbusConn() (*dbus.Conn, error) {\n\tif *systemdPrivate {\n\t\treturn dbus.NewSystemdConnectionContext(context.TODO())\n\t}\n\treturn dbus.NewWithContext(context.TODO())\n}\n\ntype unit struct {\n\tdbus.UnitStatus","sourceCodeStart":410,"sourceCodeEnd":446,"githubUrl":"https://github.com/prometheus/node_exporter/blob/17ddd77c59ba27e1508e9f7894b1e55b44d6aed3/collector/systemd_linux.go#L410-L446","documentation":"This error is returned by systemdCollector.collectSystemState when calling the D-Bus manager property GetManagerProperty(\"SystemState\") fails. systemd's SystemState property reports the overall manager state (e.g. \"running\", \"degraded\", \"maintenance\"); if the property cannot be read, the node_systemd_system_running gauge cannot be computed. The underlying D-Bus error is wrapped with %w so it can be inspected via errors.Is/As.","triggerScenarios":"The systemd D-Bus manager connection is dead or was closed; the D-Bus socket is unavailable; polkit denies the property read; systemd is being upgraded/restarted during scrape; or the connection was created without the required system bus address.","commonSituations":"Running node_exporter in a container without mounting /run/dbus/system_bus_socket; systemd restarting mid-scrape during package upgrades; missing systemd user session privileges in restricted environments; DBUS_SYSTEM_BUS_ADDRESS misconfigured.","solutions":["Verify node_exporter can talk to the system bus: check /run/dbus/system_bus_socket exists and is accessible to the exporter user","Restart node_exporter so it re-establishes the D-Bus connection after a systemd restart/upgrade","If running in a container, mount the host D-Bus socket (e.g. -v /run/dbus/system_bus_socket:/run/dbus/system_bus_socket) and run with --collector.systemd","Check journalctl for systemd/polkit errors at scrape time and ensure polkit policy allows org.freedesktop.systemd1.Manager property reads"],"exampleFix":"// before: container without dbus socket\ndocker run prom/node-exporter --collector.systemd\n// after\ndocker run -v /run/dbus/system_bus_socket:/run/dbus/system_bus_socket prom/node-exporter --collector.systemd","handlingStrategy":"try-catch","validationCode":"if _, err := os.Stat(\"/run/dbus/system_bus_socket\"); err != nil {\n    // systemd collector will fail: dbus socket unavailable\n}","typeGuard":"func dbusAvailable() bool {\n    _, err := os.Stat(\"/run/dbus/system_bus_socket\")\n    return err == nil\n}","tryCatchPattern":"if err := collector.Update(ch); err != nil {\n    var derr *dbus.Error\n    if errors.As(err, &derr) {\n        // handle dbus-level failure (reconnect, skip scrape)\n    }\n    log.Warn(\"systemd state unavailable\", \"err\", err)\n}","preventionTips":["Mount the D-Bus socket when running node_exporter in containers","Enable the systemd collector only on hosts actually running systemd","Restart the exporter after systemd upgrades if scrapes start failing","Check polkit policies permit property reads for the exporter user"],"tags":["systemd","dbus","linux","collector"],"backgroundTag":"connection-refused","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"}