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 metrics
/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