Grafana Pyroscope CPU profiling
LiteLLM proxy can send continuous CPU profiles to Grafana Pyroscope when enabled via environment variables. This is optional and off by default.
Quick start​
-
Install the optional dependency (required only when enabling Pyroscope):
pip install pyroscope-ioOr install the proxy extra:
pip install "litellm[proxy]" -
Set environment variables before starting the proxy:
Variable Required Description LITELLM_ENABLE_PYROSCOPEYes (to enable) Set to trueto enable Pyroscope profiling.PYROSCOPE_APP_NAMEYes (when enabled) Application name shown in the Pyroscope UI. PYROSCOPE_SERVER_ADDRESSYes (when enabled) Pyroscope server URL (e.g. http://localhost:4040).PYROSCOPE_SAMPLE_RATENo Sample rate (integer). If unset, the pyroscope-io library default is used. -
Start the proxy; profiling will begin automatically when the proxy starts.
export LITELLM_ENABLE_PYROSCOPE=true
export PYROSCOPE_APP_NAME=litellm-proxy
export PYROSCOPE_SERVER_ADDRESS=http://localhost:4040
litellm --config config.yaml -
View profiles in the Pyroscope (or Grafana) UI and select your
PYROSCOPE_APP_NAME.
Notes​
- Optional dependency:
pyroscope-iois an optional dependency. If it is not installed andLITELLM_ENABLE_PYROSCOPE=true, the proxy will log a warning and continue without profiling. - Platform support: The
pyroscope-iopackage uses a native extension and is not available on all platforms (e.g. Windows is excluded by the package). - Other settings: See Configuration settings for all proxy environment variables.