Skip to content

Commit 2626123

Browse files
added litellm_spend_metric
1 parent 5649c0f commit 2626123

File tree

2 files changed

+13
-9
lines changed

2 files changed

+13
-9
lines changed

enterprise/litellm_enterprise/integrations/prometheus.py

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -110,15 +110,7 @@ def __init__(
110110
self.litellm_spend_metric = self._counter_factory(
111111
"litellm_spend_metric",
112112
"Total spend on LLM requests",
113-
labelnames=[
114-
"end_user",
115-
"hashed_api_key",
116-
"api_key_alias",
117-
"model",
118-
"team",
119-
"team_alias",
120-
"user",
121-
],
113+
labelnames=self.get_labels_for_metric("litellm_spend_metric"),
122114
)
123115

124116
# Counter for total_output_tokens
@@ -321,6 +313,7 @@ def __init__(
321313
documentation="deprecated - use litellm_proxy_total_requests_metric. Total number of LLM calls to litellm - track total per API Key, team, user",
322314
labelnames=self.get_labels_for_metric("litellm_requests_metric"),
323315
)
316+
324317
except Exception as e:
325318
print_verbose(f"Got exception on init prometheus client {str(e)}")
326319
raise e

litellm/types/integrations/prometheus.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,7 @@ class UserAPIKeyLabelNames(Enum):
163163
"litellm_proxy_failed_requests_metric",
164164
"litellm_deployment_latency_per_output_token",
165165
"litellm_requests_metric",
166+
"litellm_spend_metric",
166167
"litellm_total_tokens_metric",
167168
"litellm_input_tokens_metric",
168169
"litellm_output_tokens_metric",
@@ -290,6 +291,16 @@ class PrometheusMetricLabels:
290291
UserAPIKeyLabelNames.USER_EMAIL.value,
291292
]
292293

294+
litellm_spend_metric = [
295+
UserAPIKeyLabelNames.END_USER.value,
296+
UserAPIKeyLabelNames.API_KEY_HASH.value,
297+
UserAPIKeyLabelNames.API_KEY_ALIAS.value,
298+
UserAPIKeyLabelNames.v1_LITELLM_MODEL_NAME.value,
299+
UserAPIKeyLabelNames.TEAM.value,
300+
UserAPIKeyLabelNames.TEAM_ALIAS.value,
301+
UserAPIKeyLabelNames.USER.value,
302+
]
303+
293304
litellm_input_tokens_metric = [
294305
UserAPIKeyLabelNames.END_USER.value,
295306
UserAPIKeyLabelNames.API_KEY_HASH.value,

0 commit comments

Comments
 (0)