diff --git a/litellm/integrations/prometheus.py b/litellm/integrations/prometheus.py index a3cc7b6fd32..cb668fd6900 100644 --- a/litellm/integrations/prometheus.py +++ b/litellm/integrations/prometheus.py @@ -297,20 +297,24 @@ class PrometheusLogger(CustomLogger): self.litellm_guardrail_latency_metric = self._histogram_factory( "litellm_guardrail_latency_seconds", "Latency (seconds) for guardrail execution", - labelnames=["guardrail_name", "status", "error_type", "hook_type"], + labelnames=self.get_labels_for_metric( + "litellm_guardrail_latency_seconds" + ), buckets=self._get_latency_buckets(), ) self.litellm_guardrail_errors_total = self._counter_factory( "litellm_guardrail_errors_total", "Total number of errors encountered during guardrail execution", - labelnames=["guardrail_name", "error_type", "hook_type"], + labelnames=self.get_labels_for_metric("litellm_guardrail_errors_total"), ) self.litellm_guardrail_requests_total = self._counter_factory( "litellm_guardrail_requests_total", "Total number of guardrail invocations", - labelnames=["guardrail_name", "status", "hook_type"], + labelnames=self.get_labels_for_metric( + "litellm_guardrail_requests_total" + ), ) # llm api provider budget metrics self.litellm_provider_remaining_budget_metric = self._gauge_factory( diff --git a/litellm/types/integrations/prometheus.py b/litellm/types/integrations/prometheus.py index 0856d8a6f9b..e04bef6ca18 100644 --- a/litellm/types/integrations/prometheus.py +++ b/litellm/types/integrations/prometheus.py @@ -292,9 +292,22 @@ class PrometheusMetricLabels: # Guardrail metrics - these use custom labels (guardrail_name, status, error_type, hook_type) # which are not part of UserAPIKeyLabelNames - litellm_guardrail_latency_seconds: List[str] = [] - litellm_guardrail_errors_total: List[str] = [] - litellm_guardrail_requests_total: List[str] = [] + litellm_guardrail_latency_seconds: List[str] = [ + "guardrail_name", + "status", + "error_type", + "hook_type", + ] + litellm_guardrail_errors_total: List[str] = [ + "guardrail_name", + "error_type", + "hook_type", + ] + litellm_guardrail_requests_total: List[str] = [ + "guardrail_name", + "status", + "hook_type", + ] litellm_proxy_total_requests_metric = [ UserAPIKeyLabelNames.END_USER.value,