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:
Prometheus Configuration
Createprometheus.yml:
prometheus.yml
Docker Compose with Prometheus
docker-compose.yml
http://localhost:9090
Grafana Dashboards
Setup Grafana
Add todocker-compose.yml:
Configure Data Source
Creategrafana/datasources/prometheus.yml:
Create Dashboard
Key panels to include:- Request Rate
- Latency
- Cost Tracking
- Tokens
Import Pre-built Dashboard
LiteLLM provides a Grafana dashboard JSON:- Download from LiteLLM repository
- In Grafana: Dashboards → Import → Upload JSON
- Select Prometheus data source
Logging Integrations
Langfuse
Setup:config.yaml
- Request/response traces
- Token usage and cost tracking
- User session analytics
- Model performance comparison
- Custom metadata tags
Datadog
Enable Datadog tracing:docker-compose.yml
OpenTelemetry
Configure OTEL export:config.yaml
docker-compose.yml
otel-collector-config.yml
Database Analytics
Spend Logs Table
LiteLLM stores detailed request logs in PostgreSQL:Analytics Queries
- Cost by Model
- Team Usage
- Hourly Stats
- Error Analysis
Daily Aggregates
LiteLLM maintains pre-aggregated daily statistics:Health Monitoring
Health Check Endpoints
Model Health Checks
LiteLLM automatically monitors model health:config.yaml
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
http://localhost:4000/ui
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