A lightweight metrics collector and proxy for Ollama that exposes Prometheus metrics for monitoring your LLM deployments.

Ollama Metrics Sidecar sits between your applications and Ollama, collecting metrics on:
It acts as a transparent proxy, forwarding all requests to Ollama while collecting metrics without affecting normal operation.
OLLAMA_HOST - Ollama host address (default: http://localhost:11434)PORT - Port to run the metrics server on (default: 8080)docker run -d --name ollama-metrics \
-e OLLAMA_HOST=http://ollama:11434 \
-p 8080:8080 \
ghcr.io/norskhelsenett/ollama-metrics:latest
# Run directly
go run main.go
# Build and run
go build -o ollama-metrics
./ollama-metrics
Access Prometheus metrics at http://localhost:8080/metrics
ollama_prompt_tokens_total - Total number of prompt tokens sent to the modelollama_generated_tokens_total - Total number of tokens generated by the modelollama_request_duration_seconds - Duration of Ollama requests in secondsollama_time_per_token_seconds - Time per generated token (seconds per token)ollama_loaded_models - Number of models currently loaded in memoryollama_model_loaded - Indicator (1/0) if a model is loadedollama_model_ram_mb - RAM usage in MB for each loaded modelA pre-configured Prometheus and Grafana setup is available in the prometheus/ directory:
cd prometheus
docker-compose up -d
This will start: - Prometheus for metrics collection - Grafana with pre-configured dashboard
Access Grafana at http://localhost:3000 (default credentials: admin/admin)
# Clone the repository
git clone https://github.com/NorskHelsenett/ollama-metrics.git
cd ollama-metrics
# Build
docker build -t ollama-metrics .
# Or build locally
go build -o ollama-metrics

Contributions welcome! Please feel free to submit a Pull Request.
$ claude mcp add ollama-metrics \
-- python -m otcore.mcp_server <graph>