7 views
-/https://github.com/berriai/litellm/issues/27519
GitHub · issue

#27519 LiteLLM spend meric issue (litellm_spend_metric_total)

  • State: open
  • Author: @shayan878

I’m experiencing an issue where litellm_spend_metric_total resets to zero whenever LiteLLM restarts or experiences downtime. This causes incorrect spend calculations in Grafana when using increase() or rate() functions.

**Current Query:** ``` promql sum by (model) ( clamp_min(increase(litellm_spend_metric_total[$__range]), 0) ) ``` **Problem:**

- When LiteLLM restarts, the counter metric resets to 0 - This causes increase() to calculate negative values (new value - old value) - I’m using clamp_min(..., 0) as a workaround to filter out negative spikes, but this doesn’t solve the underlying issue - For teams/groups with a single model, the calculation works correctly - For models that belong to multiple teams/groups, the spend is significantly under reported (e.g., showing 25 instead of 250) - The spend data becomes inaccurate and doesn’t reflect actual cumulative costs

**Expected Behavior:**

Counter metrics like litellm_spend_metric_total should either:

Persist across restarts (loaded from database on startup), OR Be documented as non-persistent with recommended query patterns for handling resets

**Environment:**

LiteLLM version: 1.80.8 Deployment: Docker Metr…

GitHub resolver

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

Refresh page
vote history (1 events)
#0 of 0 · 31d17h52m52s ago — entered · #import:https:::github.com:berriai:litellm post #2968
The right issue is harder because it requires changing latency-sensitive asynchronous execution, handling CPU-bound work safely, preserving streaming behavior, and validating concurrency and liveness under large workloads. The left issue is narrower, mainly involving metric lifecycle semantics, persistence or reset handling, and observability validation.
discussed in #import:https:::github.com:berriai:litellm

ranked child groups

no voted pairs yet in this scope

cli
src
spread
search