Skip to main content

AI Gateway Observability

The AI Gateway uses the same monitoring as the rest of Zerq. There is nothing to turn on for the AI Gateway itself: when the platform's Prometheus metrics, tracing and log streaming are configured, AI requests are included. The observability stack has a Zerq — AI Gateway dashboard. Prompts and answers are never added to metrics or traces.

SignalWhat you getWhere it is configured
MetricsRequests by model, provider, client and outcome; tokens; cost; latency; fallbacksMETRICS_ADDR (all Zerq metrics on one listener)
TracesOne trace per request, with every provider attempt and the call to the providerOTEL_EXPORTER_OTLP_ENDPOINT
LogsAI Logs in the console, streamed to your log platform with the request and audit logsLOG_STREAM_*
LangfuseLLM traces and generations, optionally with redacted prompts and answersAI Gateway › Settings › Exporters

Metrics​

Served on the backend's METRICS_ADDR listener with all other Zerq metrics (see Prometheus Metrics):

MetricLabels
zerq_ai_requests_totalmodel, provider (none when no provider was called), client_id, outcome (success, cache_hit or the error type, such as guardrail_blocked or upstream_unavailable)
zerq_ai_tokens_totalmodel, client_id, type (prompt or completion)
zerq_ai_cost_usd_totalmodel, client_id
zerq_ai_fallbacks_totalmodel
zerq_ai_provider_attempts_totalprovider, result (ok, error): every call to a provider, including failed attempts before a fallback
zerq_ai_provider_attempt_duration_seconds (histogram)provider
zerq_ai_request_duration_seconds (histogram, with trace exemplars)model
zerq_http_requests_total{server="ai_gateway"}method, route, code: every model API response, including requests rejected before an AI log is written (invalid AI key)

The ZerqAIProviderErrors alert fires when a model's providers fail more than 5% of requests.

Traces​

With tracing on, each model API request is a trace:

SpanNameKey attributes
RequestPOST /llm/v1/chat/completionsgen_ai.operation.name, gen_ai.request.model, gen_ai.response.model (the upstream model), gen_ai.usage.input_tokens, gen_ai.usage.output_tokens, zerq.ai.provider, zerq.ai.outcome, zerq.cost_usd, zerq.ai.cache_hit, zerq.ai.fallback_attempts, zerq.ai.guardrail_action, zerq.client_id, zerq.profile_id, error.type
Provider attemptchat gpt-4o (operation and upstream model)gen_ai.system (provider type), zerq.ai.provider, zerq.ai.model; failed attempts before a fallback are marked as errors
Provider callPOST (client span)server.address, http.response.status_code. The provider receives a traceparent header.
Guardrail checksCalls to guardrail connectors and guardrail workflows

The response carries X-Trace-ID, and the AI log entry stores the trace ID: open a trace from AI Logs or filter the logs by Trace ID (GET /api/v1/ai/logs?trace_id=). For streamed answers, the request span stays open until the stream ends, so it covers the whole answer and carries the usage, cost and outcome too.

Logs​

AI Logs keep every request in the console. With log streaming on, AI log entries are streamed with the request and audit logs (zerq.log = ai, Loki label zerq_log="ai"), with the model, provider, tokens, cost, latency, outcome and trace ID. Redacted prompts and answers are only streamed with LOG_STREAM_INCLUDE_BODIES=true and only for models that log them.

Langfuse​

Sends a trace and a generation per request to {host}/api/public/ingestion, every 5 seconds. Turn it on under AI Gateway › Settings › Exporters, store the Langfuse keys as a Basic credential (username = public key, password = secret key) and pick it in Settings.

Generations carry the upstream model, token usage, cost, latency, the provider, fallback attempts, cache hits and guardrail actions; failed requests have level ERROR and the error type. The Langfuse trace's metadata has the Zerq trace_id. The prompt and answer are included only for models that log them (redacted logging, with personal data masked); models with metadata-only logging never send text to Langfuse. Exports never slow down or fail a request; if Langfuse is down, a warning is logged and the data is dropped.

Upgrading from the AI exporters​

Earlier versions had separate OpenTelemetry and Prometheus exporters in AI Settings and an AI_METRICS_ADDR listener. They are replaced by the platform's metrics and tracing:

  • Prometheus: AI metrics keep their names and labels and are served on METRICS_ADDR. Point your scrape job at that listener. AI_METRICS_ADDR is ignored (the backend logs a warning when it is set).
  • OpenTelemetry: set OTEL_EXPORTER_OTLP_ENDPOINT (and OTEL_EXPORTER_OTLP_HEADERS) on the backend. AI spans are now part of the request's trace instead of separate traces under the zerq-ai-gateway service.
  • Saved settings for the old exporters are ignored.