Submit an issue View all issues Source
MIR-776

`miren logs system` drops structured log attributes

Done public
phinze phinze Opened Mar 10, 2026 Updated Mar 11, 2026

Problem

miren logs system output lacks structured attributes (like module, level, err, etc.), making the logs much less useful than viewing them via journalctl on the host. The bare message text is shown without any of the key-value context that slog attaches.

Example — miren logs system output:

S 2024-01-15 10:30:45: starting reconciliation

Compared to journalctl on the host:

level=INFO module=scheduler msg="starting reconciliation" app=myapp duration=2.3s

Root Cause

Two layers strip attributes:

  1. toLogEntry() in servers/logs/logs.go:26-35 — When converting from observability.LogEntry (which has a full Attributes map[string]string) to the RPC LogEntry, only the source attribute is extracted. All others (module, level, err, custom fields) are silently discarded.
  2. LogEntry RPC type in api/app/rpc.yml:281-294 — Only has fields for timestamp, line, stream, and source. No field exists for arbitrary attributes/metadata.

Data Flow

slog.Logger (attrs: module="scheduler", err="timeout", etc.)
  → SystemLogHandler writes full attrs to VictoriaLogs     ✅ stored
  → VictoriaLogs returns entries with all attrs             ✅ available
  → toLogEntry() copies only "source" attr                  ❌ dropped here
  → LogEntry RPC type has no attrs field                    ❌ can't carry them
  → printLogEntry() shows: "S 2024-01-15 10:30:45: msg"    ❌ no context

The SystemLogHandler (observability/system_log_handler.go:43-56) correctly collects all slog attributes and writes them to VictoriaLogs. The data is there; it just doesn't make it through to the CLI.

Suggested Fix

  1. Add an attributes map field to the LogEntry RPC type in api/app/rpc.yml
  2. Update toLogEntry() in servers/logs/logs.go to populate attributes from entry.Attributes
  3. Update printLogEntry() in cli/commands/logs.go to display attributes (e.g. as key=value pairs after the message)