Skip to content

Lightweight server monitoring with historical data, docker stats, and alerts.

systemd: include user journals in service logs (#2553)

Sven van Ginkel4da7d867f237
diff --git a/agent/systemd.go b/agent/systemd.go
index 7b3c29647..d24d77910 100644
--- a/agent/systemd.go
+++ b/agent/systemd.go
@@ -374,7 +374,10 @@ func (sm *systemdManager) getServiceLogs(serviceName string) (string, error) {
ctx, cancel := context.WithTimeout(context.Background(), 2100*time.Millisecond)
defer cancel()
- cmd := exec.CommandContext(ctx, "journalctl", "--system", "--quiet", "--no-pager", "--output=short-iso", "--unit", unitName, "--lines", strconv.Itoa(systemdLogsTail))
+ // No --system: journald (SplitMode=uid) stores output from services running
+ // as a non-system User= in user-UID.journal, which --system excludes.
+ // --unit still restricts results to the system unit.
+ cmd := exec.CommandContext(ctx, "journalctl", "--quiet", "--no-pager", "--output=short-iso", "--unit", unitName, "--lines", strconv.Itoa(systemdLogsTail))
output := limitedBuffer{limit: maxTotalLogSize}
cmd.Stdout = &output
stderr := limitedBuffer{limit: 1024}