BerriAI/litellm · error · ValueError

Invalid metric name: {metric_name}

Error message

Invalid metric name: {metric_name}

What it means

Error "Invalid metric name: {metric_name}" thrown in BerriAI/litellm.

Source

Thrown at litellm/integrations/prometheus.py:1014

            # Fallback to simple logging if rich is not available
            verbose_logger.error(
                "Invalid metric name: %s. Valid metrics: %s", invalid_metric_name, sorted(valid_metrics)
            )

    #########################################################
    # End of pretty print functions
    #########################################################

    def _valid_metric_name(self, metric_name: str):
        """
        Raises ValueError if the metric name is invalid and pretty prints the error
        """
        error: Final = self._validate_single_metric_name(metric_name)
        if error:
            self._pretty_print_invalid_metric_error(
                invalid_metric_name=error.metric_name, valid_metrics=error.valid_metrics
            )
            raise ValueError(error.message)

    def _pretty_print_prometheus_config(self, label_filters: dict[str, list[str]]) -> None:
        """Pretty print the processed prometheus configuration using rich"""
        try:
            from rich.console import Console
            from rich.panel import Panel
            from rich.table import Table
            from rich.text import Text

            console: Final = Console()

            # Create main panel title
            title: Final = Text("Prometheus Configuration Processed", style="bold blue")

            # Create enabled metrics table
            metrics_table: Final = Table(
                title="📊 Enabled Metrics",
                show_header=True,

View on GitHub (pinned to 6c2dcb801b)

Solutions

  1. Use a valid Prometheus metric name ([a-zA-Z_:][a-zA-Z0-9_:]*).

When it happens

Trigger: Thrown at litellm/integrations/prometheus.py:1014 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of BerriAI/litellm@6c2dcb801b (2026-08-15). Data as JSON: /api/errors/dfdc12b18a21ae4e. Report an issue: GitHub.