A Retrieval-Augmented Generation (RAG) system for DevOps knowledge management. Ingest runbooks, incident playbooks, and documentation, then query them using natural language via a FastAPI endpoint.
┌─────────────┐
│ Documents │ (Markdown, PDF, Text)
└──────┬──────┘
│
▼
┌─────────────┐
│ Chunker │ (Fixed-size, Semantic)
└──────┬──────┘
│
▼
┌─────────────┐
│ Bedrock │ (Titan Embeddings)
│ Embeddings │
└──────┬──────┘
│
▼
┌──────────────────┐
│ OpenSearch │ (Vector Store)
│ Serverless │
└──────┬───────────┘
│
▼
┌─────────────┐
│ Query │ (Natural Language)
└──────┬──────┘
│
▼
┌─────────────┐
│ Bedrock │ (Claude LLM)
│ LLM │
└──────┬──────┘
│
▼
┌─────────────┐
│ Response │ (Contextual Answer)
└─────────────┘
git clone https://github.com/hammadhaqqani/rag-ops-knowledge-base.git
cd rag-ops-knowledge-base
pip install -r requirements.txt
export AWS_REGION=us-east-1
export OPENSEARCH_COLLECTION_ENDPOINT=https://your-collection.us-east-1.aoss.amazonaws.com
export BEDROCK_MODEL_ID=anthropic.claude-v2
uvicorn app.main:app --reload --port 8000
python scripts/ingest.py --directory data/sample-runbooks
python scripts/query.py "How do I recover an EC2 instance?"
cd terraform
terraform init
terraform plan
terraform apply
terraform output opensearch_endpoint
terraform output iam_role_arn
export OPENSEARCH_COLLECTION_ENDPOINT=$(terraform output -raw opensearch_endpoint)
export AWS_REGION=$(terraform output -raw aws_region)
docker build -t rag-ops-kb .
docker push <your-ecr-repo>/rag-ops-kb:latest
POST /queryQuery the knowledge base with natural language.
Request Body:
{
"query": "How do I troubleshoot high CPU usage?",
"max_results": 5,
"min_score": 0.7
}
Response:
{
"answer": "To troubleshoot high CPU usage, first identify the process...",
"sources": [
{
"document": "high-cpu-troubleshooting.md",
"chunk_id": "chunk_123",
"score": 0.89,
"content": "Check top processes using 'top' or 'htop'..."
}
],
"query_time_ms": 245
}
POST /ingestIngest a document into the knowledge base.
Request Body:
{
"document_path": "/path/to/runbook.md",
"metadata": {
"category": "incident-response",
"author": "ops-team"
}
}
Response:
{
"status": "success",
"chunks_created": 15,
"document_id": "doc_abc123"
}
GET /healthHealth check endpoint.
Response:
{
"status": "healthy",
"opensearch_connected": true,
"bedrock_available": true
}
The application uses environment variables for configuration:
AWS_REGION: AWS region (default: us-east-1)OPENSEARCH_COLLECTION_ENDPOINT: OpenSearch Serverless collection endpointOPENSEARCH_INDEX_NAME: Index name (default: rag-ops-kb)BEDROCK_MODEL_ID: Bedrock model ID (default: anthropic.claude-v2)BEDROCK_EMBEDDING_MODEL_ID: Embedding model ID (default: amazon.titan-embed-text-v1)CHUNK_SIZE: Chunk size for text splitting (default: 1000)CHUNK_OVERLAP: Overlap between chunks (default: 200)MAX_SEARCH_RESULTS: Maximum search results (default: 5)MIN_SIMILARITY_SCORE: Minimum similarity score threshold (default: 0.7)Contributions are welcome! Please follow these steps:
git checkout -b feature/amazing-feature)git commit -m 'Add some amazing feature')git push origin feature/amazing-feature)This project is licensed under the MIT License - see the LICENSE file for details.
If you find this useful, consider buying me a coffee!