NATS JetStream
Configure NATS JetStream for the AgentShield event relay. Stream settings, TLS, consumers, and capacity.
The event relay publishes every committed security event to NATS JetStream. NATS is not on the request path: if it is unavailable, events wait in the PostgreSQL outbox and the relay's readiness reports the backlog.
Requirements
- NATS 2.10 with JetStream enabled (
-js). tls://connections for any non-loopback server in production. The relay refusesnats://to a remote host whenAGENTSHIELD_ENV=production.
NATS_URL=tls://nats.internal:4222Stream
The relay creates or updates the stream on startup:
| Setting | Value |
|---|---|
| Name | AGENTSHIELD_EVENTS |
| Subjects | agentshield.events.> |
| Max age | 7 days |
| Duplicate window | 10 minutes |
Each message's subject is agentshield.events.<organization id>.<event type> and its Nats-Msg-Id is the event id, so a republish after a relay crash is dropped inside the duplicate window.
Consumers
The relay creates one durable consumer:
| Consumer | Filter | Policy |
|---|---|---|
evidence | agentshield.events.*.content.flagged, agentshield.events.*.tool.failed | Explicit ack, 30 s ack wait, at most 8 deliveries, deliver all |
Create your own durable consumers for integrations. See Event streaming.
Accounts and permissions
Give the relay a NATS user that can publish to agentshield.events.>, manage the AGENTSHIELD_EVENTS stream, and consume through the evidence consumer. Give downstream consumers read-only access to the subjects they need, for example one organization's prefix.
Capacity
Every authorize and execute produces at least one event. Over the seven-day retention, plan JetStream storage for roughly:
(tool calls per day) × 2 events × (average payload size) × 7Payloads are redacted canonical JSON. Arguments are included in redacted form, so large arguments produce large events.
Development
Compose runs nats:2.10-alpine with JetStream on 127.0.0.1:4222 and monitoring on 127.0.0.1:8222. The Kubernetes dev overlay runs NATS in-cluster with nats://.
Implementation references
Was this page helpful?