Logging and correlation ids

Release status: 3.0.0 and develop
Logs go to stderr. Relata does not store, rotate or ship them; your container runtime or service manager does that. Released 3.0.0 has level, format, per-crate targets, the /admin/logs ring, X-Request-Id and the live event stream. Log channels (and ?channel=), message ids, redaction markers (and relata logs --redact), request fields on log lines from the inner modules and the query_id in the slow-query warning are on develop. "On develop" means merged in the product repository but not in a release yet.

Level, format and targets

SettingDefaultMeaning
RELATA_LOG_LEVELwarnerror, warn, info, debug or trace.
RELATA_LOG_FORMATpretty on a terminal, json otherwiseSet json explicitly for log shippers.
RELATA_LOG_TARGETSunsetPer-crate levels, such as relata_storage=debug,relata_query=warn, and log channels (below).

A malformed value stops startup; it is never ignored.

RELATA_LOG_FORMAT=json RELATA_LOG_LEVEL=warn \
RELATA_LOG_TARGETS=relata_storage=debug \
relata serve

At the default warn level the boot timeline still logs at info under the target relata_boot: one boot phase finished line per phase with elapsed_ms, and a heartbeat every 30 seconds, so a slow restart names its phase.

Log channels

A channel groups events by who acts on them, across crates. It is the tracing target relata::<channel>, so a JSON line carries it as "target".

ChannelWhat it carries today
opsConfiguration errors at startup, the listener lines, cache close at shutdown
healthLow disk at boot, remote backend and key-service readiness failures
sessionsEvery authentication failure (with reason), mTLS principal failures, unknown token roles
sensitive_accessBreak-glass grants, protected reads withheld because the audit refused them
perfCPU shed gate closed and reopened, CPU above the warning level, slow background work, slow queries
jobsDetection jobs dead-lettered, panicked or alerting; forget-scheduler retractions

Other events keep their crate target and no channel.

In RELATA_LOG_TARGETS, a channel name means relata::<channel>=info, and <channel>=<level> sets its level. A bare level replaces the RELATA_LOG_LEVEL floor, so off,<channel> emits one channel alone:

RELATA_LOG_TARGETS=off,sessions,sensitive_access   # a security review stream
RELATA_LOG_TARGETS=jobs=debug                      # everything at the floor, plus jobs at debug

A channel is a filter, not a separate sink. To send one channel to its own file, filter on "target":"relata::<channel>" in your log shipper.

Message ids and modules

A converted log line carries a stable msg_id (RLM-<MODULE>-<NNNN>) and a module field. An id never changes meaning, so alert and search on the id, not the text. The wal module is fully converted, and some acl, audit, cache, http, ingest, jobs, query and storage lines have ids. The log message catalogue lists every id with its level, text and source file.

Redaction markers

A log line never prints a user value. Where code logs one, it prints a marker instead:

  • ‹redacted:secret› for a credential;
  • ‹redacted:<class>:<8 hex>› for other values, such as pii or literal.

The 8-hex tag is keyed with a random per-process key. Equal values share a tag within one run, so you can see that two lines refer to the same value without seeing it. Tags do not match across restarts.

relata logs --redact and relata support-bundle run the same strip pass over lines already written: SQL literals, credentials and payload-named fields. A JSON log line stays valid JSON after the pass.

The log ring on the admin listener

The node keeps the last 500 log events that passed the log filter in memory. Read them without shell access to the host:

# last 100 lines as text (default 50, at most 500)
curl -s -H "Authorization: Bearer $RELATA_ADMIN_TOKEN" \
  "http://127.0.0.1:9091/admin/logs?lines=100" | jq -r '.lines[]'
 
# one channel, as structured events
curl -s -H "Authorization: Bearer $RELATA_ADMIN_TOKEN" \
  "http://127.0.0.1:9091/admin/logs?channel=sessions&format=json&lines=100" | jq '.events[]'

An unknown channel answers 400. Credential-named fields are masked in this ring.

Correlation ids

Every data-plane request has one id.

  • Send your own X-Request-Id and the server adopts it if it is 8 to 128 characters from A-Z a-z 0-9 . _ : -. Anything else is replaced with a server-minted UUID v7.
  • The id is returned in the X-Request-ID header, in the request_id member of an error body, in the audit record and in the access-log line.
  • Every log line written while the request is served, including lines from the query, storage, ACL, graph and identity code, sits inside an http.request span with request_id, door, tenant and purpose. JSON logs include that span. Background work runs in jobs.<job> spans with a job_id.
  • The access-log line is written for every mutating request, every task poll and every failure. Plain successful reads, health and readiness probes, and /metrics are not logged.
ID=$(uuidgen)
curl -s -H "X-Request-Id: $ID" -H "Authorization: Bearer $RELATA_API_KEY" \
  -H 'Content-Type: application/json' \
  -d '{"sql":"SELECT * FROM Person LIMIT 1"}' http://127.0.0.1:9090/v1/query
 
# the log lines of that request
curl -s -H "Authorization: Bearer $RELATA_ADMIN_TOKEN" \
  "http://127.0.0.1:9091/admin/logs?lines=500&format=json" | jq --arg id "$ID" '.events[] | select(tostring | contains($id))'
 
# its audit record
curl -s -H "Authorization: Bearer $RELATA_API_KEY" \
  "http://127.0.0.1:9090/v1/audit/log?request_id=$ID" | jq .

A query that crosses the slow-query threshold writes a slow query warning (on develop: id RLM-QUERY-0002, channel perf) with door, query_id, request_id, duration_ms, threshold_ms and sql_bytes. It never writes the statement text. query_id is the statement's shape fingerprint, so you can find every run of the same shape (see Diagnosing a slow query).

Live event stream

GET /v1/observe/stream is a server-sent event stream with one event per request stage (received, completed, failed). It is off unless RELATA_OBSERVE_STREAM=true.

What is coming

Message ids on the log lines of the remaining modules are tracked in #7849.