Skip to main content
Version: 5.0.x 🚧

Event Schema Reference

Applies to MTE Relay v5 (5.0.x)

This schema applies to MTE Relay v5 (MRS and MAR). It is the contract every monitoring integration on this site builds against.

MTE Relay emits all logs as one JSON object per line on stderr (zerolog). No custom parsing rules are needed in Datadog, New Relic, Loki, CloudWatch Logs Insights, Splunk, or Elastic.

Configuration​

Env varDefaultEffect
LOG_LEVELinfoFilters all output including events. Security/error events emit at warn/error and survive LOG_LEVEL=warn.
USE_CONSOLE_LOGSfalsePretty console output for local dev. Never enable where an aggregator ingests logs.
PERF_EVENT_SAMPLE_PERCENT100Percentage of per-request performance events emitted (0–100). Security, error, and encryption events are never sampled.

Envelope fields (every line)​

FieldDescription
timeRFC3339 timestamp
leveltrace debug info warn error fatal panic
messageHuman-readable summary
serviceAlways mte-relay
productmrs (client→server) or mar (server→server gateway)
relay_versione.g. 5.0.0
instanceHostname of the emitting container
correlation_idPresent on request-scoped lines

Structured events add exactly one nested object under one of these keys: encryption_event, security_event, performance_event, error_event. The same correlation_id appears on every line and event a single request produces.

performance_event​

Two event types, both subject to PERF_EVENT_SAMPLE_PERCENT:

  • request_timing β€” every request (including pass-through and errors): total_time_ms, status_code, request_path, request_method.
  • phase_breakdown β€” every relayed request: adds decryption_ms, validation_ms, proxy_ms, encryption_ms, encrypted_data_bytes, decrypted_data_bytes, client_id, pair_id.

security_event​

Fields: event_type, severity (low/medium/high/critical), origin (client IP), reason, client_id, pair_id, success. Severity maps to log level: low β†’ info, medium β†’ warn, high/critical β†’ error.

event_typeSeverityMeaning
auth_invalid_tokenlowInvalid client ID signature during auth; new ID generated
keepalive_invalid_client_idmediumInvalid client ID signature on keepalive
pair_invalid_client_idhighInvalid client ID signature during pairing
invalid_client_idmediumClient ID signature validation failed on a relay request
client_pairs_exhaustedlowNo pairs for client; full re-pair required (capacity signal)
pair_not_foundmediumPair state missing β€” expired or never created (possible replay)
state_restore_failedhighEncoder/decoder state restore failed β€” potential corruption
state_not_foundhighState missing from the state store
state_save_failedhighFailed to persist state (Redis health signal)

encryption_event​

Audit trail of MTE operations. Plaintext is never logged β€” only SHA-256 hashes.

  • event_type: decryption, direction: inbound_request β€” after request decode
  • event_type: encryption, direction: outbound_response β€” after response encode

Fields: correlation_id, eeid (unique event ID), url_payload_hash (SHA-256), url_payload_length, decryption_time_ms / encryption_time_ms, mte_type (MKE/MTE), data_size_bytes, client_id, pair_id, origin, upstream_host, success. Streaming payloads are not audit-hashed (no full body is ever buffered).

error_event​

Fields: event_type, severity, message, reason, error_code, stack_trace. Current catalog: panic (critical) β€” a recovered handler panic with full stack trace.

Operational lines worth dashboarding​

  • "Request completed" β€” per-request: method, path, status_code, duration_ms, correlation_id.
  • "Perf stats." β€” interval-aggregated stage histograms, only when ENABLE_PERF_STATS=true.

Vendor guides​

  • Datadog β€” pipeline, facets/measures, dashboard, monitors
  • New Relic β€” dashboard, alert policy
  • Grafana β€” CloudWatch Logs Insights and Loki dashboards