Observability Architecture
Prometheus metrics on dedicated ports, tenant-safe labels, structured logs, the Grafana dashboard, alert rules, and benchmarks.
AgentShield is multi-tenant, and a metrics endpoint is usually scraped by infrastructure that tenants do not control. Its observability design starts from that constraint: platform totals are public to the monitoring system; per-tenant detail stays behind control plane roles.
Signals
| Signal | Where | Contains |
|---|---|---|
| Prometheus metrics | Each service, on a dedicated port | Rates, latencies, outcomes, with fixed-set labels only |
| Structured logs | Process stdout (JSON in Go) | One line per request: trace id, span id, route, duration. Never bodies or content |
| Security events | PostgreSQL, then NATS | Per-organization, redacted, hash-chained. See Event processing |
| Reliability metrics | reliability_metrics table | Per-organization, per-tool minute rows, read through the control plane |
| Health | /health/live, /health/ready | Liveness and dependency readiness |
Metrics ports
| Service | Variable | From source | In the image |
|---|---|---|---|
| Gateway | GATEWAY_METRICS_ADDR | 127.0.0.1:9081 | 0.0.0.0:9081 |
| Control plane | CONTROL_PLANE_METRICS_ADDR | 127.0.0.1:9080 | 0.0.0.0:9080 |
| Intelligence | INTELLIGENCE_METRICS_ADDR | 127.0.0.1:9082 | 0.0.0.0:9082 |
| Event relay | RELAY_HTTP_ADDR (with health) | 127.0.0.1:8083 | 0.0.0.0:8083 |
A metrics address must differ from the service's API address, and each service refuses to start otherwise. Metrics are therefore never reachable through the API's ingress by accident. off disables a listener. Compose does not publish metrics ports; Kubernetes network policies admit only pods labelled agentshield.io/metrics-scraper: "true".
Label policy
No metric carries an organization, agent, user, resource, or request id. Every label value comes from a fixed set: route names, outcomes, registered tool names, and known rule ids. Anything else is recorded as other or unregistered. This bounds cardinality, so a caller cannot create series with crafted paths, and a scrape reveals nothing about any one tenant.
Key metrics
| Metric | Labels | Meaning |
|---|---|---|
agentshield_gateway_http_requests_total | route, code | Gateway requests |
agentshield_gateway_decisions_total | outcome | allow, deny, require_approval |
agentshield_gateway_executions_total | tool, result | completed, timeout, or a failure code such as circuit_open |
agentshield_gateway_adapter_duration_seconds | tool | Time inside the adapter |
agentshield_gateway_analysis_total | status | clean, flagged, unavailable |
agentshield_relay_outbox_backlog | — | Events waiting; -1 when unreadable |
agentshield_relay_outbox_oldest_seconds | — | Age of the oldest waiting event |
The complete list is on the Prometheus page.
Dashboards and alerts
The Compose observability profile runs Prometheus v3.1.0 and Grafana 11.4.0, pinned by digest, on loopback ports. The AgentShield dashboard and data source are provisioned from files. Eight alert rules ship with Prometheus, covering service availability, gateway errors, open circuits, analyzer availability, injection spikes, outbox lag, and evidence write failures. See Grafana and Monitoring.
No Alertmanager is configured by default. Alerts are visible in Prometheus and Grafana; add an Alertmanager with your own receivers to page someone.
Per-tenant visibility
Operators who need per-organization numbers use the control plane, which applies roles:
GET /api/v1/metrics/reliabilityfor per-tool calls, failures, success rate, and latency.GET /api/v1/eventsand the/api/v1/events/streamserver-sent events for activity.GET /api/v1/incidentsandGET /api/v1/alertsfor detections.
Benchmarks
Go benchmarks measure policy evaluation, signature verification, and a full in-memory authorization; a Python script measures the analyzer. benchmarks/README.md records a baseline with the machine and conditions. CI runs the benchmarks to make sure they still execute.
Direction
Metrics and health cover the current operational needs. Distributed tracing with an OpenTelemetry collector, log shipping, and long-term metric storage are natural extensions; services already emit trace and span ids in their request logs, and the event stream is the integration point for external security tooling.
Implementation references
Was this page helpful?
Data Storage Architecture
The PostgreSQL schema, how tenant isolation and append-only guarantees are enforced in the database, and what lives in Redis, NATS, and MinIO.
Deployment Architecture
How AgentShield is packaged and deployed. Hardened containers, Docker Compose profiles, Kubernetes overlays, network policy, and signed releases.