Merge pull request #2752 from BerriAI/litellm_grafana_metrics

[Fix + Docs] grafana / prometheus metrics
This commit is contained in:
Ishaan Jaff 2024-03-29 14:38:45 -07:00 committed by GitHub
commit e40a86d37a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 12 additions and 6 deletions

View file

@ -4,6 +4,8 @@ LiteLLM Exposes a `/metrics` endpoint for Prometheus to Poll
## Quick Start ## Quick Start
If you're using the LiteLLM CLI with `litellm --config proxy_config.yaml` then you need to `pip install prometheus_client==0.20.0`. **This is already pre-installed on the litellm Docker image**
Add this to your proxy config.yaml Add this to your proxy config.yaml
```yaml ```yaml
model_list: model_list:
@ -34,6 +36,12 @@ curl --location 'http://0.0.0.0:4000/chat/completions' \
}' }'
``` ```
View Metrics on `/metrics`, Visit `http://localhost:4000/metrics`
```shell
http://localhost:4000/metrics
# <proxy_base_url>/metrics
```
## Metrics Tracked ## Metrics Tracked

View file

@ -43,8 +43,5 @@ model_list:
model: openai/fake model: openai/fake
api_key: fake-key api_key: fake-key
api_base: https://exampleopenaiendpoint-production.up.railway.app/ api_base: https://exampleopenaiendpoint-production.up.railway.app/
general_settings: litellm_settings:
master_key: sk-1234 success_callback: ["prometheus"]
disable_spend_logs: true
disable_reset_budget: true
num_retries: 2

View file

@ -6235,6 +6235,7 @@ def set_callbacks(callback_list, function_id=None):
elif callback == "datadog": elif callback == "datadog":
dataDogLogger = DataDogLogger() dataDogLogger = DataDogLogger()
elif callback == "prometheus": elif callback == "prometheus":
if prometheusLogger is None:
prometheusLogger = PrometheusLogger() prometheusLogger = PrometheusLogger()
elif callback == "dynamodb": elif callback == "dynamodb":
dynamoLogger = DyanmoDBLogger() dynamoLogger = DyanmoDBLogger()