The gateway now ships in the
praisonai-bot package. praisonai serve gateway still works exactly as documented here; for a standalone install see praisonai-bot Migration.GET /metrics on the PraisonAI gateway to feed Prometheus — counters and gauges for every hop of the message flow, zero new dependencies.
GET /metrics while messaging the gateway; counters and gauges record inbound, agent, and outbound hops.
Quick Start
How It Works
Gauges are sampled on every scrape — not pushed on a timer. The/metrics endpoint calls _refresh_metric_gauges() before rendering, so active_sessions and channel_recoveries always reflect the live gateway state.
Configuration Options
Authentication
The/metrics endpoint uses the same _check_auth gate as other operational endpoints (e.g. /info).
| Method | How |
|---|---|
| Cookie session | Active browser session |
| Loopback bypass | Requests from 127.0.0.1 / ::1 bypass token check |
| Bearer token | Authorization: Bearer <token> header |
| Query param | ?token=<token> (deprecated) |
401 if token is required but missing; 403 on token mismatch.
If
auth_token is not set in the gateway config, the endpoint is open to all callers. Set auth_token before binding to non-loopback addresses.Counters
| Name | Help |
|---|---|
messages_inbound_total | Total inbound messages received by the gateway. |
messages_dispatched_total | Total inbound messages dispatched to an agent run. |
messages_duplicate_total | Total inbound messages dropped as duplicates. |
outbound_sent_total | Total outbound messages successfully delivered. |
outbound_failed_total | Total outbound messages that failed delivery. |
approval_pending_total | Total approval requests created. |
approval_decided_total | Total approval requests decided (allowed or denied). |
channel_errors_total | Total channel errors observed by supervision. |
channel_restarts_total | Total channel restarts performed by supervision. |
Gauges
| Name | Help |
|---|---|
outbox_depth | Current number of messages pending outbound delivery. |
approval_pending | Current number of approvals awaiting a decision. |
active_sessions | Current number of active gateway sessions. |
channel_recoveries | Total supervision recoveries per channel. |
labels dict (string→string). Channel-scoped metrics use labels={"channel": <name>}. Labels are rendered as sorted, deterministic name{a="b",c="d"} value.
Common Patterns
Recording a custom counter
Fetching a JSON snapshot in tests
Prometheus scrape config
Using GatewayMetrics directly
Best Practices
Set auth_token before binding to non-loopback
Set auth_token before binding to non-loopback
Always configure
auth_token in gateway.yaml when your gateway binds to 0.0.0.0 or a public address. Without it, /metrics is open to the network.Use a scrape interval of 5s or longer
Use a scrape interval of 5s or longer
Gauges are sampled on each scrape. Scraping more frequently than every 5 seconds wastes resources without adding useful resolution — gateway state changes at human timescales.
Alert on outbound_failed_total and channel_restarts_total
Alert on outbound_failed_total and channel_restarts_total
These two counters surface delivery problems immediately. Configure Prometheus alerting rules on their rates:
Don't depend on push frequency for gauges
Don't depend on push frequency for gauges
active_sessions, outbox_depth, and approval_pending are point-in-time samples taken at scrape time — they are not time-averaged. Use them as snapshots, not as rate inputs.Metrics show rates and totals; for per-turn latency and error spans, attach a hook via Gateway Tracing Hook.
Related
Bind-Aware Auth
The same
_check_auth / loopback model used by /metrics — understand how token auth and loopback bypass work together.Correlation IDs
Join ingress, session, and agent-run logs on one stable id per message.
Gateway Server
Multi-bot WebSocket gateway — the host that exposes
/metrics.BotOS
The full bot operating system layer above the gateway.
Tracing Hook
The other observability rail — per-stage OpenTelemetry spans alongside these counters.

