Prometheus RAG: A natural language interface for Prometheus metrics using RAG (Retrieval-Augmented Generation)
Prometheus RAG bridges the gap between natural language and Prometheus metrics by implementing a Retrieval-Augmented Generation (RAG) system. It allows users to query metrics using plain English, automatically finding relevant metrics and generating appropriate PromQL queries.
Key features:
-
Natural language to PromQL translation
-
Automatic metric metadata synchronization
-
Vector similarity search for relevant metrics
-
BERT-based encoding for semantic understanding
-
Integration with vector database
This guide will help you set up and run Prometheus RAG locally for development.
- Podman/Docker and Podman/Docker Compose
- Go 1.21+
- Access to an LLM server
-
Start VectorDB and Prometheus
Launch the development Qdrant VectorDB and Prometheus server:
# You can use podman or docker cd hack && docker compose up -d
-
Configure LLM Server
Ensure you have a running LLM server and set these required environment variables:
export PRAG_LLM_BASE_URL="your-llm-server-url" export PRAG_LLM_API_KEY="your-api-key"
-
Start RAG Server
Launch the RAG application:
go run main.go
-
Test the Service
Send a test query:
curl -X POST \ http://localhost:8080/query \ -H "Content-Type: application/json" \ -d '{"query": "What is the total number of VMs?"}'
The application can be configured using the following environment variables:
Variable | Description | Default |
---|---|---|
PRAG_DEBUG |
Enable debug logging | false |
PRAG_HOST |
Server host address | 0.0.0.0 |
PRAG_PORT |
Server port | 8080 |
Variable | Description | Default |
---|---|---|
PRAG_PROMETHEUS_ADDRESS |
Prometheus server URL | http://localhost:9090 |
PRAG_PROMETHEUS_REFRESH_RATE_MINUTES |
Metadata refresh interval | 10 |
Variable | Description | Default |
---|---|---|
PRAG_VECTORDB_HOST |
Qdrant server host | localhost |
PRAG_VECTORDB_PORT |
Qdrant server port | 6334 |
PRAG_VECTORDB_COLLECTION |
Collection name | prag-metrics |
PRAG_VECTORDB_ENCODER_DIR |
Encoder models directory | ./_models |
Variable | Description | Default |
---|---|---|
PRAG_LLM_BASE_URL |
LLM server base URL | http://localhost:1234/v1/ |
PRAG_LLM_API_KEY |
Authentication key | |
PRAG_LLM_MODEL |
Model identifier | granite-3.1-8b-instruct |