Skip to Content
AgentShield
Self-Hosting

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 refuses nats:// to a remote host when AGENTSHIELD_ENV=production.
NATS_URL=tls://nats.internal:4222

Stream

The relay creates or updates the stream on startup:

SettingValue
NameAGENTSHIELD_EVENTS
Subjectsagentshield.events.>
Max age7 days
Duplicate window10 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:

ConsumerFilterPolicy
evidenceagentshield.events.*.content.flagged, agentshield.events.*.tool.failedExplicit 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) × 7

Payloads 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://.

Was this page helpful?

On this page