A production-ready API monitoring system powered by Large Language Models (Groq/Llama 3), LangGraph, and Vector Databases (Pinecone).
- Real-time Dashboard: Live "Matrix-style" monitoring of API health.
- AI Analysis: Every log analyzed by Llama 3 for sentiment, errors, and insights.
- Anomaly Detection: Statistical (z-score) and semantic anomaly detection.
- Vector Search: Semantic storage of logs in Pinecone.
- Cost Tracking: Token usage and cost estimation.
- Backend: FastAPI, Python 3.9+
- AI Orchestraion: LangGraph, LangChain
- LLM: Groq (Llama 3.3-70b)
- Database: MongoDB (Logs/KPIs), Pinecone (Vectors)
- Frontend: HTML5, Tailwind CSS, WebSockets
You can connect any software application (Python, Node.js, Java, Go, etc.) to this monitoring system.
Simply send a POST request to the /logs endpoint whenever your app handles a request.
import requests
import time
def log_to_monitor(endpoint, method, status_code, start_time):
latency = (time.time() - start_time) * 1000 # ms
payload = {
"endpoint": endpoint,
"method": method,
"status_code": status_code,
"latency": latency,
"response_size": 1024, # Optional
"error": None # Optional error message
}
try:
# Send to the monitoring system (assuming running locally)
requests.post("http://localhost:8000/logs", json=payload)
except Exception as e:
print(f"Failed to log: {e}")
# Usage Example
start = time.time()
# ... process your API request ...
log_to_monitor("/api/generate-email", "POST", 200, start)const axios = require('axios');
async function logToMonitor(endpoint, method, statusCode, startTime) {
const latency = Date.now() - startTime;
const payload = {
endpoint: endpoint,
method: method,
status_code: statusCode,
latency: latency,
response_size: 512,
error: null
};
try {
await axios.post('http://localhost:8000/logs', payload);
} catch (error) {
console.error('Monitoring failed:', error.message);
}
}
// Usage Example
const start = Date.now();
// ... handle request ...
logToMonitor('/api/chat', 'POST', 200, start);- Clone the repository
- Install dependencies:
pip install -r requirements.txt - Configure Environment:
- Rename
.env.exampleto.env - Add your Groq API Key
- Add MongoDB URI
- Add Pinecone API Key
- Rename
- Run the System:
- Linux/Mac:
./run.sh - Windows:
python main.py
- Linux/Mac:
Access the live dashboard at: http://localhost:8000/
Run the test data generator to see it in action:
python test_data_generator.py continuous 1