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
1
Start the gateway with auth_token set
2
Scrape the metrics endpoint
3
Read the Prometheus exposition output
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).
Returns
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
Gauges
Labels: Counters and gauges accept an arbitrary
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 bind-aware loopback bypass (permissive on loopback by default) that also protects
/metrics — understand how token auth and the 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.
Hot-Reload Observability
Last reload outcome, watcher liveness, and config drift via
health().Tracing Hook
The other observability rail — per-stage OpenTelemetry spans alongside these counters.

