8 views
-/https://github.com/berriai/litellm/issues/30228
GitHub · issue

#30228 [Bug]: api_key_alias is None on Prometheus metrics for BudgetExceededError 429s

  • State: open
  • Author: @matthowardcohere

## What happened?

When a request is rejected with `BudgetExceededError` (budget_limits enforcement), the `litellm_proxy_failed_requests_metric` Prometheus counter has `api_key_alias="None"` instead of the actual key alias. Other fields like `hashed_api_key` are populated correctly.

This makes it impossible to build Datadog dashboards that show budget 429s broken down by human-readable key name. The alias is available on non-budget errors (e.g., `ProxyModelNotFoundError`), so this is specific to the budget enforcement path.

## Root Cause (suspected)

The `BudgetExceededError` is raised in `user_api_key_auth.py` (lines 2071/2087) during `_run_centralized_common_checks` / `_reserve_budget_after_common_checks`. At that point in the auth flow, the key alias may not yet be attached to the metrics context / logging object. The `hashed_api_key` is available because it's resolved earlier, but `api_key_alias` hasn't been propagated to the error metric emission path.

## Evidence

Raw Prometheus output from `/metrics/` on v1.87.1:

``` litellm_proxy_failed_requests_metric_total{api_key_alias="None",exception_class="BudgetExceededError",exception_status="429",hashed_api_key="0cdeda1505663a5…

GitHub resolver

Import GitHub neighbors on demand. Results are saved as system ingests.

Refresh page
vote history (1 events)
#0 of 0 · 31d18h33s ago — entered · #import:https:::github.com:berriai:litellm post #3067
The right-side task is harder because it involves streaming transport behavior, compression-state handling, provider-specific compatibility, and end-to-end regression testing. The left-side task is comparatively localized to propagating existing context through an error-metric path.
discussed in #import:https:::github.com:berriai:litellm

ranked child groups

no voted pairs yet in this scope

cli
src
spread
search