Open documentation index
Getting startedOverviewInstallationQuick startCore concepts
ConfigurationConfiguration referenceProvidersRouting and failoverRate limiting
OperationsStorageObservabilitySecurityTUI dashboardAI routing
ReferenceCLI referenceAdmin APITroubleshooting
Docs/Operations/Observability
Operations

Observability

Inspect metrics, structured logs, request IDs, key state, and stored request history.

Request IDs and structured logging

Every proxied response includes an X-ModelMux-Request-ID header. Use it to correlate client failures with ModelMux logs and, when available, AI route traces.

Application logs are emitted with Go's structured log/slog package and include request method, path, remote address, and latency.

Metrics endpoints

HTTP
GET /metrics
GET /metrics?format=prometheus

The default response is JSON. Add format=prometheus for Prometheus exposition format.

MetricMeaning
modelmux_requests_totalRequests by model, key, and group.
modelmux_errors_totalObserved error counts.
modelmux_rate_limits_totalLocal or upstream rate-limit events.
modelmux_latency_msLatency histogram with predefined millisecond buckets.
modelmux_status_totalResponse status classes such as 2xx, 4xx, and 5xx.
modelmux_active_keysCurrently active-key gauge.
cooldown_keysKeys currently cooling down.
invalid_keysKeys marked invalid.
limited_keysKeys unavailable due to local limits.

Request logs

Request history can include the selected group, model, provider, key, status code, latency, input/output token counts, estimated cost when available, and timestamp.

In-memory mode retains a bounded recent buffer. SQLite mode keeps persistent history and allows later queries through the CLI and HTTP endpoint.

Query request history

CLI
modelmux logs --limit 50
modelmux logs --model-id example-chat
modelmux logs --status-code 429
modelmux logs --json --limit 100
HTTP
GET /logs?limit=50
GET /logs?model_id=example-chat
GET /logs?status_code=429

JSON CLI output is useful for scripts, incident reports, and ingestion into other tooling.

What to monitor

  • Error and status rate: watch 429 and 5xx growth by model and provider.
  • Latency: alert on sustained p95 or p99 changes, not isolated slow requests.
  • Key capacity: monitor active, cooldown, invalid, and limited key counts.
  • Quota headroom: inspect daily request and token consumption before exhaustion.
  • Failover frequency: repeated failover can indicate provider degradation or incorrect local limits.
  • Storage growth: manage request-log retention and database size in long-running deployments.