A comprehensive, enterprise-grade health monitoring system for microservices architecture built with FastAPI, MongoDB, Docker, and Prometheus. Features AI-powered root cause analysis using Ollama LLaMA 3 and a modern frontend dashboard.
- Microservices: Auth, Order, Catalog (FastAPI, MongoDB, Prometheus metrics)
- Prometheus Monitoring: System, business, and HTTP metrics for all services
- AI Root Cause Analysis: Ollama LLaMA 3 integration for incident analysis
- Structured Logging: JSON logs, real-time log analysis, anomaly detection
- Comprehensive Dashboard: Real-time health, metrics, analytics, logs, and AI insights
- Docker Compose Orchestration: Easy local development and deployment
βββββββββββββββββ βββββββββββββββββ βββββββββββββββββ
β Auth Service β β Order Service β β Catalog Svc β
β 8001/8002 β β 8003/8004 β β 8005/8006 β
ββββββββ¬βββββββββ ββββββββ¬βββββββββ ββββββββ¬βββββββββ
β β β
βββββββββββββββ¬ββββββ΄ββββββ¬ββββββββββββββ
β β
βββββββββΌββββββββββββΌββββββββ
β MongoDB (27017) β
βββββββββββββββ¬ββββββββββββββ
β
ββββββββββΌβββββββββ
β Prometheus β
β (9090) β
ββββββββββ¬βββββββββ
β
βββββββββββββββββββΌββββββββββββββββββ
β Monitoring Engine (8000) β
β Controller (traffic gen) β
β Frontend Dashboard (React) β
βββββββββββββββββββββββββββββββββββββ
- User registration & sign-in (JWT)
- MongoDB for user storage
- Prometheus metrics: auth attempts, JWTs, DB ops, system
/register,/signin,/ping,/health,/metrics
- Place and view orders (JWT required)
- MongoDB for orders
- Prometheus metrics: order ops, DB ops, system
/api/v1/order,/api/v1/orders,/ping,/health,/metrics
- Product catalog CRUD (JWT required)
- MongoDB for products
- Prometheus metrics: product ops, stock updates, DB ops, system
/api/v1/add_product,/api/v1/update_stock,/api/v1/product,/api/v1/all_products,/ping,/health,/metrics
- Aggregates logs, metrics, and Prometheus data
- AI-powered root cause analysis via Ollama
- Endpoints:
/api/health,/api/summary,/api/metrics,/api/performance,/api/analytics,/api/root_cause,/api/errors/analysis,/api/logs,/api/services,/api/ollama/test
- Generates synthetic traffic and error scenarios for testing
- React app for real-time monitoring, analytics, logs, and AI insights
- Auto-refresh, manual refresh, color-coded status, error toasts
- HTTP Metrics:
http_requests_total,http_request_duration_seconds,response_time_ms - Business Metrics:
auth_attempts_total,order_operations_total,product_operations_total,stock_updates_total - Database Metrics:
db_operations_total,db_operation_duration_seconds - System Metrics:
cpu_percent,memory_used_mb,process_start_time_seconds - Error Metrics:
errors_total,error_types,order_404,http_500,auth_failures - JWT Metrics:
jwt_tokens_issued_total,jwt_token_validations_total
- Docker & Docker Compose
- Python 3.8+
- Ollama (for AI analysis, optional)
-
Clone the repository
git clone <repository-url> cd health-monitoring-auth_service_dev
-
Start all services
docker-compose up --build
-
Access the system:
- Frontend Dashboard: http://localhost:8000
- Prometheus: http://localhost:9090
- Mongo Express: http://localhost:8081
- Auth Service: http://localhost:8001
- Order Service: http://localhost:8003
- Catalog Service: http://localhost:8005
-
Seed the catalog (optional):
python seed_catalog.py
-
Test endpoints:
- Register/sign in, get a JWT, and use it for order/catalog APIs.
- Use
/api/root_causefor AI analysis.
GET /api/healthβ System healthGET /api/summaryβ Metrics summaryGET /api/metricsβ Detailed metricsGET /api/performanceβ Performance analyticsGET /api/analyticsβ AnalyticsGET /api/root_causeβ AI root cause analysisGET /api/errors/analysisβ Error analysisGET /api/logsβ LogsGET /api/servicesβ Per-service metricsGET /api/ollama/testβ Ollama diagnostics
POST /registerβ Register userPOST /signinβ Sign in (returns JWT)GET /ping,GET /health,GET /metrics
POST /api/v1/orderβ Place order (JWT)GET /api/v1/ordersβ List user orders (JWT)GET /ping,GET /health,GET /metrics
POST /api/v1/add_productβ Add product (JWT)POST /api/v1/update_stockβ Update stock (JWT)GET /api/v1/productβ Search products (JWT)GET /api/v1/all_productsβ List all products (JWT)GET /ping,GET /health,GET /metrics
- JWT-based authentication for all protected endpoints
- Secure password hashing (bcrypt)
- Service-to-service authentication
- Environment variable configuration
- All services log to
/app/logs/metrics.log(mounted to./logs) - View logs in real time via dashboard or
docker logs <service> - Prometheus logs:
docker logs prometheus - Debug endpoints:
/api/debug/*
/api/root_causeand dashboard button use Ollama LLaMA 3 for incident analysis- Detects error spikes, latency anomalies, service-specific issues
- Returns actionable recommendations
- Controller generates traffic and errors
- Use
seed_catalog.pyto add products - Manual API testing with curl/Postman
.envfor secrets and DB URIsdocker-compose.yamlfor service orchestrationprometheus/prometheus.ymlfor metrics scraping