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
prometheus log_success_fallback_event
Ishaan Jaffd1eedb04bd26
diff --git a/litellm/integrations/prometheus.py b/litellm/integrations/prometheus.pyindex 1425b101c09..8e31bca137b 100644--- a/litellm/integrations/prometheus.py+++ b/litellm/integrations/prometheus.py@@ -170,6 +170,17 @@ class PrometheusLogger(CustomLogger):labelnames=_logged_llm_labels,)+ self.llm_deployment_successful_fallbacks = Counter(+ "llm_deployment_successful_fallbacks",+ "LLM Deployment Analytics - Number of successful fallback workloads",+ ["primary_model", "fallback_model"],+ )+ self.llm_deployment_failed_fallbacks = Counter(+ "llm_deployment_failed_fallbacks",+ "LLM Deployment Analytics - Number of failed fallback workloads",+ ["primary_model", "fallback_model"],+ )+except Exception as e:print_verbose(f"Got exception on init prometheus client {str(e)}")raise e@@ -479,6 +490,28 @@ class PrometheusLogger(CustomLogger):)return+ async def log_success_fallback_event(self, original_model_group: str, kwargs: dict):+ verbose_logger.debug(+ "Prometheus: log_success_fallback_event, original_model_group: %s, kwargs: %s",+ original_model_group,+ kwargs,+ )+ _new_model = kwargs.get("model")+ self.llm_deployment_successful_fallbacks.labels(+ primary_model=original_model_group, fallback_model=_new_model+ ).inc()++ async def log_failure_fallback_event(self, original_model_group: str, kwargs: dict):+ verbose_logger.debug(+ "Prometheus: log_failure_fallback_event, original_model_group: %s, kwargs: %s",+ original_model_group,+ kwargs,+ )+ _new_model = kwargs.get("model")+ self.llm_deployment_failed_fallbacks.labels(+ primary_model=original_model_group, fallback_model=_new_model+ ).inc()+def set_deployment_state(self,state: int,diff --git a/litellm/proxy/proxy_config.yaml b/litellm/proxy/proxy_config.yamlindex c16d09e72c2..8d499c1c0f3 100644--- a/litellm/proxy/proxy_config.yaml+++ b/litellm/proxy/proxy_config.yaml@@ -37,5 +37,6 @@ general_settings:master_key: sk-1234litellm_settings:+ fallbacks: [{"gemini-1.5-pro-001": ["gpt-4o"]}]success_callback: ["langfuse", "prometheus"]failure_callback: ["prometheus"]