LLM Metrics

Track LLM request latency, token usage, and billed spend across providers and models. See Labels for request and agent dimensions.

Metrics

MetricTypeExtra LabelsMeasures
llm_request_duration_secondsHistogramstatus_codeUpstream-call latency; streaming measures establishment, not completion. Retries can add observations.
llm_proxy_request_duration_secondsHistogramprovider, operation, stream, outcome, error_origin, status_code onlyEnd-to-end logical proxy and unified model API inference duration, including preflight, retries, and full stream completion
llm_tokens_totalCountertype (input, output)Tokens used. input excludes prompt-cache tokens.
llm_cache_tokens_totalCountercache_type (read, write)Prompt-cache tokens read from or written to the provider cache
llm_token_usageHistogramInput plus output tokens per request
llm_cost_totalCounterbilling_mode, auth_methodEstimated list-price cost in USD. Needs model pricing.
llm_cache_cost_totalCounterCost in USD of prompt-cache reads and writes
llm_cache_savings_totalCounterUSD saved by cache reads at the discounted price
llm_time_to_first_token_secondsHistogramStreaming: from the upstream call to the provider's first chunk
llm_time_to_first_byte_secondsHistogramStreaming: from request receipt to the first byte sent to the client
llm_tokens_per_secondHistogramOutput token throughput
llm_blocked_tools_totalCounterTool calls blocked by guardrails
agent_runs_totalCounterexternal_agent_idUnique runs, counted by the X-Archestra-Run-Id header
llm_active_usersGaugewindow (24h, 7d) onlyDistinct users with at least one LLM request in the window

Billing and Authentication Labels

billing_mode is metered for per-token billing and subscription for flat-rate subscription credentials. Billed spend is sum(llm_cost_total{billing_mode="metered"}). auth_method is provider_key, virtual_key, passthrough_virtual_key, jwks, oauth_client_credentials, oauth_user, internal, or unknown.

Streaming Latency

For one request, the difference between client first-byte and upstream first-chunk times includes work before the upstream call, such as authentication and guardrails. Do not subtract aggregate percentiles to estimate that duration.

Active User Aggregation

Every replica reports the same llm_active_users value, so aggregate it with max(), not sum(). ARCHESTRA_METRICS_ACTIVE_USERS_REFRESH_INTERVAL_MS sets the refresh interval; 0 turns the metric off.

Trace Exemplars

Upstream LLM latency, token, cache, and cost observations can carry trace exemplars. See Exemplars for collection requirements.

Proxy Request Outcomes

Track end-to-end request outcomes, throttling, and latency across the LLM Proxy and unified model API with llm_proxy_request_duration_seconds, separating Archestra policy decisions from upstream provider and client failures.

Each observation records one logical inference request from handler entry through completion, including preflight, retries, failovers, and the full response stream. Use llm_proxy_request_duration_seconds_count as the request counter; Archestra does not emit a separate counter metric. Use the existing llm_request_duration_seconds for upstream-call latency: its count can include retries, and misses preflight refusals and failures after streaming headers.

The metric covers inference requests handled by the shared proxy and unified model API. It excludes requests rejected by authentication or validation before reaching those handlers, model listing, unsupported passthrough endpoints, and provider file routes.

LabelValues
providerResolved provider name (such as openai or anthropic), or router when a unified-model request fails before routing selects a provider
operationInference operation, such as chat, generate_content, or embedding
streamtrue or false
outcomesuccess, incomplete, error, throttled, denied, cancelled, timeout, or overloaded
error_originnone for success or incomplete, archestra, provider, or client
status_codeHTTP response status code (100–599, normalized to 500 if invalid, or 499 when the client disconnects before headers are sent)

incomplete identifies a provider terminal such as an output-token limit; it has no error origin.

If a streaming request fails after HTTP 200 headers are sent, status_code stays 200 while outcome and error_origin record the midstream failure. To keep cardinality bounded, this histogram carries only the six labels above and omits model, agent, user, team, and key dimensions. For per-request attribution, use the metadata-only archestra.llm_proxy.request OpenTelemetry log event in Proxy Request Log Events; existing token, cache, and cost metrics above, costs and limits, and LLM spans keep their existing dimensions.

Scrape Archestra's standard /metrics endpoint to collect this histogram, and query llm_proxy_request_duration_seconds_count for throttle and error rates:

promql
# Upstream provider rate limits (requests/sec by provider)
sum by (provider) (
  rate(llm_proxy_request_duration_seconds_count{outcome="throttled", error_origin="provider"}[5m])
)

# Internal Archestra throttles and policy or limit denials (requests/sec)
sum by (outcome) (
  rate(llm_proxy_request_duration_seconds_count{outcome=~"throttled|denied", error_origin="archestra"}[5m])
)

# Non-success request rate by origin and outcome, including midstream 200 failures
sum by (provider, error_origin, outcome) (
  rate(llm_proxy_request_duration_seconds_count{outcome!="success"}[5m])
)