2025-02-08 20:25:15 +08:00
# Prometheus and Grafana
2024-01-31 14:58:07 -08:00
2025-02-08 20:25:15 +08:00
This is a simple example that shows you how to connect vLLM metric logging to the Prometheus/Grafana stack. For this example, we launch Prometheus and Grafana via Docker. You can checkout other methods through [Prometheus ](https://prometheus.io/ ) and [Grafana ](https://grafana.com/ ) websites.
Install:
2024-01-31 14:58:07 -08:00
- [`docker` ](https://docs.docker.com/engine/install/ )
- [`docker compose` ](https://docs.docker.com/compose/install/linux/#install-using-the-repository )
2025-01-08 01:20:12 +00:00
## Launch
2024-01-31 14:58:07 -08:00
Prometheus metric logging is enabled by default in the OpenAI-compatible server. Launch via the entrypoint:
2025-02-08 20:25:15 +08:00
2024-01-31 14:58:07 -08:00
```bash
2024-07-17 15:43:21 +08:00
vllm serve mistralai/Mistral-7B-v0.1 \
2025-08-02 00:19:48 -07:00
--max-model-len 2048
2024-01-31 14:58:07 -08:00
```
Launch Prometheus and Grafana servers with `docker compose` :
2025-02-08 20:25:15 +08:00
2024-01-31 14:58:07 -08:00
```bash
docker compose up
```
Submit some sample requests to the server:
2025-02-08 20:25:15 +08:00
2024-01-31 14:58:07 -08:00
```bash
wget https://huggingface.co/datasets/anon8231489123/ShareGPT_Vicuna_unfiltered/resolve/main/ShareGPT_V3_unfiltered_cleaned_split.json
2025-07-26 21:02:12 -07:00
vllm bench serve \
2024-01-31 14:58:07 -08:00
--model mistralai/Mistral-7B-v0.1 \
--tokenizer mistralai/Mistral-7B-v0.1 \
--endpoint /v1/completions \
2024-05-30 01:26:33 +03:00
--dataset-name sharegpt \
--dataset-path ShareGPT_V3_unfiltered_cleaned_split.json \
2024-01-31 14:58:07 -08:00
--request-rate 3.0
```
Navigating to [`http://localhost:8000/metrics` ](http://localhost:8000/metrics ) will show the raw Prometheus metrics being exposed by vLLM.
2025-01-08 01:20:12 +00:00
## Grafana Dashboard
2024-01-31 14:58:07 -08:00
Navigate to [`http://localhost:3000` ](http://localhost:3000 ). Log in with the default username (`admin` ) and password (`admin` ).
2025-01-08 01:20:12 +00:00
### Add Prometheus Data Source
2024-01-31 14:58:07 -08:00
2025-02-08 20:25:15 +08:00
Navigate to [`http://localhost:3000/connections/datasources/new` ](http://localhost:3000/connections/datasources/new ) and select Prometheus.
2024-01-31 14:58:07 -08:00
2025-11-19 07:52:30 +01:00
On Prometheus configuration page, we need to add the `Prometheus Server URL` in `Connection` . For this setup, Grafana and Prometheus are running in separate containers, but Docker creates DNS name for each container. You can just use `http://prometheus:9090` .
2024-01-31 14:58:07 -08:00
Click `Save & Test` . You should get a green check saying "Successfully queried the Prometheus API.".
2025-02-08 20:25:15 +08:00
### Import Dashboard
2024-01-31 14:58:07 -08:00
Navigate to [`http://localhost:3000/dashboard/import` ](http://localhost:3000/dashboard/import ), upload `grafana.json` , and select the `prometheus` datasource. You should see a screen that looks like the following:
