Subscribing to Events
Stream a session's interception events as JSON with mirrord subscribe
mirrord subscribe lets you stream live events from an active mirrord session — HTTP requests, queue messages, and operator notifications as JSON to stdout. It's useful in CI/tests: assert that a request actually got stolen to your local process instead of silently hitting the real service, so a broken interception fails the build instead of going green.
When do you receive events?
HTTP - you receive an event for each request/response that was routed to or from a target workload by mirrord and matches your subscribed key.
Queue (Amazon SQS, Azure Service Bus, GCP Pub/Sub, RabbitMQ, BullMQ, Kafka, Redis Pub/Sub) - while queue splitting is active, you receive an event for each message that matches your subscribed key. If no splitting session is active, no events are received.
In both cases: no active mirrord session = no events.
HTTP events come from redirected requests/responses. Queue events require queue splitting configured for the session, and every supported broker emits them, with these exceptions:
Temporal is not currently supported.
Kafka Streams consumers are not currently supported (standard Kafka consumers are).
Need support for more events? Open a GitHub issue or reach out in the mirrord Slack community
Prerequisites
A running session started with a known key:
mirrord exec --key <KEY> .... If you don't pass--key, the key defaults to your OS username.
Usage
In one terminal, run the session you want to observe:
mirrord exec --key my-key -t deployment/my-app -- <cmd>In another, subscribe to its events:
mirrord subscribe --key my-keyThe key can also come from the key field in your mirrord config (e.g. mirrord subscribe -f mirrord.json)
Events stream to stdout, one compact JSON object per line, as the operator intercepts traffic for that key. Status messages go to stderr, so you can pipe events straight into jq:
You may also pass --pretty to pretty-print each event.
Events
Every event has the same envelope — service_name, timestamp, and a data payload:
(examples are pretty-printed for clarity; actual output is compact unless --pretty is passed)
To work with just the payload, extract .data with jq:
data is one of the following (payloads shown on their own):
http_request— an intercepted (stolen) request:
http_response— the response to a stolen request:
queue_message— a queue message routed to your session.queue_typeis one ofsqs,azure_service_bus,gcppubsub,rmq, orbullmq.message_idandcorrelation_idare included only when the broker provides them (SQS, GCP Pub/Sub and BullMQ have nocorrelation_id).propertiesis the message's attribute bag, with values stringified: text as-is, and binary values base64-encoded.
An Azure Service Bus message (its application properties become properties):
An SQS message, where the payload message attribute was binary (its bytes come back base64-encoded):
A GCP Pub/Sub message. queue_name is the subscription being split, and properties are the message's attributes:
A RabbitMQ message. queue_name is the queue the message was consumed from, and properties are the AMQP headers:
A BullMQ job. message_id is the job ID, and properties are the top-level fields of the job's data payload — the same fields BullMQ splits filter on:
kafka_message— a Kafka message stolen to your session. Kafka uses a different schema thanqueue_message:topic,partition,offset, an optionalkey, andheaders(values stringified — text as-is, binary base64). There is noqueue_typeorcorrelation_id.
redis_message— a Redis Pub/Sub message relayed to your session. Redis also uses a different schema: just thechannelthe message was published to and itspayload_sizein bytes. Pub/Sub messages carry no ID, headers, or attribute bag, and the payload itself is not included.
For a pattern subscription (PSUBSCRIBE), channel is the concrete channel the message arrived on — not the pattern. So an app subscribed to orders.* that receives a message on orders.created reports:
lagged— your consumer fell behind and the operator droppedcountevents:
Lagging takes place whenever the consumer is not able to keep up with the messages and receive them in a timely fashion (e.g. due to a slow network connection). By default, the operator buffers up to 2048 messages (configurable in values.yaml through subscribeEventBufferSize), and lagging will take place if more than this many messages accumulate in the internal buffer without the consumer receiving them. Note that lagging only affects slow consumers — functioning consumers will continue to receive all events even in the presence of slow peers.
Direct Kube API access (no mirrord CLI required)
mirrord subscribe is a thin wrapper over an operator endpoint that emits Server-Sent Events (text/event-stream). You can access it directly through the Kubernetes API, without requiring the mirrord CLI:
or with kubectl proxy + curl:
watch=true is necessary to stop the Kube API server from cutting out the stream after ~60s.
Last updated
Was this helpful?

