Event Streaming
Consume AgentShield security events from NATS JetStream. Subjects, message format, durable consumers, and integration patterns.
Every committed security event is published to NATS JetStream by the event relay. Subscribe to feed a SIEM, trigger workflows, or build analytics, without touching the gateway's request path.
Stream and subjects
| Property | Value |
|---|---|
| Stream | AGENTSHIELD_EVENTS |
| Subject | agentshield.events.<organization id>.<event type> |
| Retention | 7 days |
| Deduplication | Nats-Msg-Id = event id, 10-minute window |
Event types are already dotted, so subject filters compose naturally:
| Filter | Receives |
|---|---|
agentshield.events.> | Everything |
agentshield.events.<org>.> | One organization |
agentshield.events.*.tool.* | tool.executed and tool.failed, all organizations |
agentshield.events.*.content.flagged | Content analysis findings |
agentshield.events.<org>.authorization.decided | One organization's decisions |
Message format
{
"id": "6d0c2b4e-…",
"organization_id": "9a7e5d2c-…",
"agent_id": "3f2b8c1e-…",
"execution_id": "c4d6e8f0-…",
"event_type": "authorization.decided",
"occurred_at": "2026-11-30T12:00:00.123456Z",
"payload": {
"arguments": { "headers": { "Accept": "application/json" } },
"operation": "http.get",
"outcome": "allow",
"reason": "allowed",
"resource": "https://api.github.com/repos/octo/hello",
"tool_name": "http.request"
},
"audit_hash": "4be1…"
}payload is the redacted payload stored in PostgreSQL. agent_id and execution_id are null for events not tied to them, such as member changes.
Create a durable consumer
nats consumer add AGENTSHIELD_EVENTS siem-forwarder \
--filter 'agentshield.events.>' \
--ack explicit --deliver all --max-deliver 10 --pullProcess messages idempotently by id. Delivery is at least once; the relay's deduplication window removes publisher-side duplicates, but your consumer can still see redelivery after a missed ack.
Delivery guarantees
| Guarantee | Detail |
|---|---|
| Only committed events | The outbox is filled by a trigger in the writer's transaction; rolled-back changes are never published |
| No loss while the relay is down | Events wait in event_outbox |
| Ordering | Preserved per relay; run one relay replica |
| History | Seven days in the stream; the full history remains in PostgreSQL |
Patterns
- SIEM forwarding. A consumer on
agentshield.events.>that writes to your SIEM, keyed byid. - Alert routing. A consumer on
*.content.flaggedand*.tool.failedthat opens tickets. - Analytics. Aggregate decisions per organization and tool into an analytical store. Treat it as a reporting copy; PostgreSQL remains the source of truth for authorization.
Evidence
The relay's own evidence consumer turns content.flagged and tool.failed events into bundles in object storage. Do not reuse that consumer name.
Implementation references
Was this page helpful?