Skip to main content

Overview

LiteLLM provides built-in observability through:
  • Prometheus metrics - Request rates, latency, errors
  • Logging integrations - Langfuse, Datadog, OpenTelemetry
  • Database tracking - Spend logs, usage analytics
  • Health checks - Service and model health monitoring

Prometheus Metrics

Enable Metrics Endpoint

LiteLLM exposes Prometheus metrics at /metrics:
Available metrics:

Prometheus Configuration

Create prometheus.yml:
prometheus.yml

Docker Compose with Prometheus

docker-compose.yml
Start:
Access Prometheus UI: http://localhost:9090

Grafana Dashboards

Setup Grafana

Add to docker-compose.yml:

Configure Data Source

Create grafana/datasources/prometheus.yml:

Create Dashboard

Key panels to include:

Import Pre-built Dashboard

LiteLLM provides a Grafana dashboard JSON:
  1. Download from LiteLLM repository
  2. In Grafana: DashboardsImport → Upload JSON
  3. Select Prometheus data source

Logging Integrations

Langfuse

Langfuse provides detailed LLM observability with traces, costs, and user analytics.
Setup:
config.yaml
Environment variables:
Features:
  • Request/response traces
  • Token usage and cost tracking
  • User session analytics
  • Model performance comparison
  • Custom metadata tags

Datadog

Enable Datadog tracing:
Docker with Datadog Agent:
docker-compose.yml

OpenTelemetry

Configure OTEL export:
config.yaml
Docker with OTEL Collector:
docker-compose.yml
OTEL Collector config:
otel-collector-config.yml

Database Analytics

Spend Logs Table

LiteLLM stores detailed request logs in PostgreSQL:

Analytics Queries

Daily Aggregates

LiteLLM maintains pre-aggregated daily statistics:

Health Monitoring

Health Check Endpoints

Response format:

Model Health Checks

LiteLLM automatically monitors model health:
config.yaml
View health status:

Alerting Rules

Prometheus alerting rules:
alerts.yml

Admin Dashboard

LiteLLM includes a built-in admin UI at /ui: Features:
  • Real-time request logs
  • Cost analytics and spend tracking
  • Model performance metrics
  • Team and user management
  • API key management
  • Health status overview
Access: http://localhost:4000/ui
Use LITELLM_MASTER_KEY to authenticate to the admin dashboard.

Best Practices

1

Enable Multiple Backends

Don’t rely on a single monitoring solution:
2

Set Up Alerts

Configure alerts for:
  • High error rates (>5%)
  • High latency (P95 >5s)
  • Model failures
  • Cost spikes
  • Rate limit exhaustion
3

Retain Logs

Keep logs for compliance and debugging:
4

Tag Everything

Use metadata for filtering:

Next Steps

Performance

Optimize latency and throughput

Security

Secure your deployment

Troubleshooting

Debug common issues

High Availability

Deploy for production at scale