llama-server can expose Prometheus metrics: counters and gauges for prompt speed, token speed, cache use and request counts. The –metrics flag turns the endpoint on, and any tool that speaks Prometheus can scrape it. This guide enables it and reads the numbers with curl.
Before you start
- llama.cpp installed, with llama-server on your PATH.
- A GGUF model file, for example a Qwen3 8B Q4_K_M file.
- curl, and optionally a Prometheus server if you want to store the numbers.
Start the server with metrics
Start the server with the flag:
llama-server -m qwen3-8b-q4_k_m.gguf --metrics --port 8080
The server loads the model and listens on port 8080.
Fetch the metrics endpoint
Ask the server for its metrics:
curl http://localhost:8080/metrics
The reply is plain text in Prometheus format, one metric per line, with help text above each group.
Read the key numbers
Look for the prompt-processing speed, the token-generation speed and the cache usage lines, and send a prompt first so the counters are not zero. Note the numbers down, then send a longer prompt and fetch the endpoint again to see them move.
Worked example
Worked example: send the prompt “Write a four-line poem about rain.” and then fetch the metrics. The token-generation speed line should show a number in tokens per second, and the request counter should have gone up by one since the previous fetch.
Expected result
UNTESTED in this guide: no server was run while writing it. The expected result is that /metrics returns Prometheus text, and the token speed and request count move after a prompt is sent.
Limitations
The metrics endpoint is for monitoring, not for chatting, and it exposes server internals, so do not publish the port on a public network without access control. The exact metric names depend on the llama.cpp version.
