The fastest, litest AI Gateway. Rust core with Python SDK. Call 100+ LLM APIs in OpenAI (or native) format with cost tracking, guardrails, load balancing, and logging [Bedrock, Azure, OpenAI, Anthropic, OpenAI, VertexAI, vLLM, Nvidia NIM]
Python ai-gatewayanthropicazure-openaibedrockgatewaylangchainlitellmllmllm-gatewayllmopsmcp-gatewayopenaiopenai-proxyrustrust-aivertex-ai
added prometheus metrics
mubashir1osmaniaf2f447698be
diff --git a/enterprise/litellm_enterprise/integrations/prometheus.py b/enterprise/litellm_enterprise/integrations/prometheus.pyindex a2d781fa1c4..1aa2359bc15 100644--- a/enterprise/litellm_enterprise/integrations/prometheus.py+++ b/enterprise/litellm_enterprise/integrations/prometheus.py@@ -95,13 +95,14 @@ class PrometheusLogger(CustomLogger):self.litellm_llm_api_time_to_first_token_metric = self._histogram_factory("litellm_llm_api_time_to_first_token_metric","Time to first token for a models LLM API call",- labelnames=[- "model",- "hashed_api_key",- "api_key_alias",- "team",- "team_alias",- ],+ # labelnames=[+ # "model",+ # "hashed_api_key",+ # "api_key_alias",+ # "team",+ # "team_alias",+ # ],+ labelnames=self.get_labels_for_metric("litellm_llm_api_time_to_first_token_metric"),buckets=LATENCY_BUCKETS,)@@ -255,13 +256,14 @@ class PrometheusLogger(CustomLogger):self.litellm_deployment_state = self._gauge_factory("litellm_deployment_state","LLM Deployment Analytics - The state of the deployment: 0 = healthy, 1 = partial outage, 2 = complete outage",- labelnames=_logged_llm_labels,+ labelnames=self.get_labels_for_metric("litellm_deployment_state"))self.litellm_deployment_cooled_down = self._counter_factory("litellm_deployment_cooled_down","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",- labelnames=_logged_llm_labels + [EXCEPTION_STATUS],+ # labelnames=_logged_llm_labels + [EXCEPTION_STATUS],+ labelnames=self.get_labels_for_metric("litellm_deployment_cooled_down"))self.litellm_deployment_success_responses = self._counter_factory(diff --git a/litellm/types/integrations/prometheus.py b/litellm/types/integrations/prometheus.pyindex e0ee950d260..4ab0ccf5022 100644--- a/litellm/types/integrations/prometheus.py+++ b/litellm/types/integrations/prometheus.py@@ -154,6 +154,7 @@ class UserAPIKeyLabelNames(Enum):DEFINED_PROMETHEUS_METRICS = Literal["litellm_llm_api_latency_metric",+ "litellm_llm_api_time_to_first_token_metric","litellm_request_total_latency_metric","litellm_overhead_latency_metric","litellm_remaining_requests_metric",@@ -173,9 +174,11 @@ DEFINED_PROMETHEUS_METRICS = Literal["litellm_remaining_api_key_budget_metric","litellm_api_key_max_budget_metric","litellm_api_key_budget_remaining_hours_metric",+ "litellm_deployment_state","litellm_deployment_failure_responses","litellm_deployment_total_requests","litellm_deployment_success_responses",+ "litellm_deployment_cooled_down","litellm_pod_lock_manager_size","litellm_in_memory_daily_spend_update_queue_size","litellm_redis_daily_spend_update_queue_size",@@ -191,9 +194,14 @@ class PrometheusMetricLabels:UserAPIKeyLabelNames.API_KEY_ALIAS.value,UserAPIKeyLabelNames.TEAM.value,UserAPIKeyLabelNames.TEAM_ALIAS.value,- UserAPIKeyLabelNames.REQUESTED_MODEL.value,- UserAPIKeyLabelNames.END_USER.value,- UserAPIKeyLabelNames.USER.value,+ ]++ litellm_llm_api_time_to_first_token_metric = [+ UserAPIKeyLabelNames.v1_LITELLM_MODEL_NAME.value,+ UserAPIKeyLabelNames.API_KEY_HASH.value,+ UserAPIKeyLabelNames.API_KEY_ALIAS.value,+ UserAPIKeyLabelNames.TEAM.value,+ UserAPIKeyLabelNames.TEAM_ALIAS.value,]litellm_request_total_latency_metric = [@@ -315,6 +323,20 @@ class PrometheusMetricLabels:UserAPIKeyLabelNames.REQUESTED_MODEL.value,]+ litellm_deployment_state = [+ UserAPIKeyLabelNames.v2_LITELLM_MODEL_NAME.value,+ UserAPIKeyLabelNames.MODEL_ID.value,+ UserAPIKeyLabelNames.API_BASE.value,+ UserAPIKeyLabelNames.API_PROVIDER.value,+ ]++ litellm_deployment_cooled_down = [+ UserAPIKeyLabelNames.v2_LITELLM_MODEL_NAME.value,+ UserAPIKeyLabelNames.MODEL_ID.value,+ UserAPIKeyLabelNames.API_BASE.value,+ UserAPIKeyLabelNames.API_PROVIDER.value,+ ]+litellm_deployment_successful_fallbacks = [UserAPIKeyLabelNames.REQUESTED_MODEL.value,UserAPIKeyLabelNames.FALLBACK_MODEL.value,