Skip to content

Commit af2f447

Browse files
added prometheus metrics
1 parent a8f2ebe commit af2f447

File tree

2 files changed

+36
-12
lines changed

2 files changed

+36
-12
lines changed

enterprise/litellm_enterprise/integrations/prometheus.py

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -95,13 +95,14 @@ def __init__(
9595
self.litellm_llm_api_time_to_first_token_metric = self._histogram_factory(
9696
"litellm_llm_api_time_to_first_token_metric",
9797
"Time to first token for a models LLM API call",
98-
labelnames=[
99-
"model",
100-
"hashed_api_key",
101-
"api_key_alias",
102-
"team",
103-
"team_alias",
104-
],
98+
# labelnames=[
99+
# "model",
100+
# "hashed_api_key",
101+
# "api_key_alias",
102+
# "team",
103+
# "team_alias",
104+
# ],
105+
labelnames=self.get_labels_for_metric("litellm_llm_api_time_to_first_token_metric"),
105106
buckets=LATENCY_BUCKETS,
106107
)
107108

@@ -255,13 +256,14 @@ def __init__(
255256
self.litellm_deployment_state = self._gauge_factory(
256257
"litellm_deployment_state",
257258
"LLM Deployment Analytics - The state of the deployment: 0 = healthy, 1 = partial outage, 2 = complete outage",
258-
labelnames=_logged_llm_labels,
259+
labelnames=self.get_labels_for_metric("litellm_deployment_state")
259260
)
260261

261262
self.litellm_deployment_cooled_down = self._counter_factory(
262263
"litellm_deployment_cooled_down",
263264
"LLM Deployment Analytics - Number of times a deployment has been cooled down by LiteLLM load balancing logic. exception_status is the status of the exception that caused the deployment to be cooled down",
264-
labelnames=_logged_llm_labels + [EXCEPTION_STATUS],
265+
# labelnames=_logged_llm_labels + [EXCEPTION_STATUS],
266+
labelnames=self.get_labels_for_metric("litellm_deployment_cooled_down")
265267
)
266268

267269
self.litellm_deployment_success_responses = self._counter_factory(

litellm/types/integrations/prometheus.py

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,7 @@ class UserAPIKeyLabelNames(Enum):
154154

155155
DEFINED_PROMETHEUS_METRICS = Literal[
156156
"litellm_llm_api_latency_metric",
157+
"litellm_llm_api_time_to_first_token_metric",
157158
"litellm_request_total_latency_metric",
158159
"litellm_overhead_latency_metric",
159160
"litellm_remaining_requests_metric",
@@ -173,9 +174,11 @@ class UserAPIKeyLabelNames(Enum):
173174
"litellm_remaining_api_key_budget_metric",
174175
"litellm_api_key_max_budget_metric",
175176
"litellm_api_key_budget_remaining_hours_metric",
177+
"litellm_deployment_state",
176178
"litellm_deployment_failure_responses",
177179
"litellm_deployment_total_requests",
178180
"litellm_deployment_success_responses",
181+
"litellm_deployment_cooled_down",
179182
"litellm_pod_lock_manager_size",
180183
"litellm_in_memory_daily_spend_update_queue_size",
181184
"litellm_redis_daily_spend_update_queue_size",
@@ -191,9 +194,14 @@ class PrometheusMetricLabels:
191194
UserAPIKeyLabelNames.API_KEY_ALIAS.value,
192195
UserAPIKeyLabelNames.TEAM.value,
193196
UserAPIKeyLabelNames.TEAM_ALIAS.value,
194-
UserAPIKeyLabelNames.REQUESTED_MODEL.value,
195-
UserAPIKeyLabelNames.END_USER.value,
196-
UserAPIKeyLabelNames.USER.value,
197+
]
198+
199+
litellm_llm_api_time_to_first_token_metric = [
200+
UserAPIKeyLabelNames.v1_LITELLM_MODEL_NAME.value,
201+
UserAPIKeyLabelNames.API_KEY_HASH.value,
202+
UserAPIKeyLabelNames.API_KEY_ALIAS.value,
203+
UserAPIKeyLabelNames.TEAM.value,
204+
UserAPIKeyLabelNames.TEAM_ALIAS.value,
197205
]
198206

199207
litellm_request_total_latency_metric = [
@@ -315,6 +323,20 @@ class PrometheusMetricLabels:
315323
UserAPIKeyLabelNames.REQUESTED_MODEL.value,
316324
]
317325

326+
litellm_deployment_state = [
327+
UserAPIKeyLabelNames.v2_LITELLM_MODEL_NAME.value,
328+
UserAPIKeyLabelNames.MODEL_ID.value,
329+
UserAPIKeyLabelNames.API_BASE.value,
330+
UserAPIKeyLabelNames.API_PROVIDER.value,
331+
]
332+
333+
litellm_deployment_cooled_down = [
334+
UserAPIKeyLabelNames.v2_LITELLM_MODEL_NAME.value,
335+
UserAPIKeyLabelNames.MODEL_ID.value,
336+
UserAPIKeyLabelNames.API_BASE.value,
337+
UserAPIKeyLabelNames.API_PROVIDER.value,
338+
]
339+
318340
litellm_deployment_successful_fallbacks = [
319341
UserAPIKeyLabelNames.REQUESTED_MODEL.value,
320342
UserAPIKeyLabelNames.FALLBACK_MODEL.value,

0 commit comments

Comments
 (0)