Monitoring: journald → vlagent dual-write log shipping (flakes-m1as)
Ship journald from every monitored host to all hubs.
Spec
- Package:
pkgs.victorialogs.override { withVlAgent = true; withServer = false; }(vlagent not built by default). - Custom systemd unit
vlagent(no NixOS module exists):DynamicUser,StateDirectory, listen127.0.0.1:9429,-remoteWrite.urlonce per hub,-tmpDataPathin state dir for per-URL persistent queues. services.journald.upload:settings.Upload.URL = "http://127.0.0.1:9429/insert/journald"(vlagent accepts the journald protocol via vlinsert handler — verified in v1.49 source).- Stream fields: set
-journald.streamFields(e.g._HOSTNAME,_SYSTEMD_UNIT,PRIORITY) on the hub VL or vlagent — check which side applies them when forwarding. - Add
host/sitefields if not already carried by_HOSTNAME.
Todo
- vlagent package override + systemd unit
- journald upload → local vlagent
- Verify in both hub UIs:
_SYSTEMD_UNIT:sshd.servicefrom both hosts - Verify buffering across a hub outage
Summary of Changes
mixins/nixos/services/monitoring/logs.nix:systemd-journal-upload→ localvlagent(127.0.0.1:9429, built viavictorialogs.override { withVlAgent = true; }, custom unit since there is no NixOS module) → every hub’s VictoriaLogs, per-URL disk queue (1GB cap each).- Hub ingest URL corrected to
/insert/native(vlagent’s documented endpoint;/internal/insertis the cluster-internal protocol). - Stream fields: vlagent applies them itself; defaults
_MACHINE_ID,_HOSTNAME,_SYSTEMD_UNITkept. No extra host/site fields:systemd-journal-uploadappends/uploadto its URL so query-string extra fields are not an option, and_HOSTNAMEalready identifies the host. - First-start backfill limited to the retention window: an
ExecStartPreseeds the upload cursor at the last entry older thanmonitoring.retention.logs(30d), instead of pushing the full ~4G journal (back to May on pc) across sites only for hubs to discard it. - Deployed on pc and edger (2026-10-08). Backfill finished in ~90s: both hubs hold edger ≈7.3M and pc ≈3.3M entries for 30d; ~138M on disk per hub.
- Verified:
_SYSTEMD_UNIT:sshd.servicereturns both hosts on both hubs; buffering — stopped edger’s VictoriaLogs, logged a marker on pc (vlagent retried), restarted, marker reached edger ~6s later.