Skip to content

sachin9536/Application_Performance_Monitor_Dynamic

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

1 Commit
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ₯ Health Monitoring System for Microservices

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.


πŸš€ Features

  • 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

πŸ—οΈ Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”   β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”   β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ 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)        β”‚
         β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

πŸ“¦ Services Overview

Auth Service

  • User registration & sign-in (JWT)
  • MongoDB for user storage
  • Prometheus metrics: auth attempts, JWTs, DB ops, system
  • /register, /signin, /ping, /health, /metrics

Order Service

  • 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

Catalog Service

  • 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

Monitoring Engine

  • 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

Controller

  • Generates synthetic traffic and error scenarios for testing

Frontend Dashboard

  • React app for real-time monitoring, analytics, logs, and AI insights
  • Auto-refresh, manual refresh, color-coded status, error toasts

πŸ“Š Metrics Collected

  • 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

πŸ› οΈ Setup & Usage

Prerequisites

  • Docker & Docker Compose
  • Python 3.8+
  • Ollama (for AI analysis, optional)

Quick Start

  1. Clone the repository

    git clone <repository-url>
    cd health-monitoring-auth_service_dev
  2. Start all services

    docker-compose up --build
  3. Access the system:

  4. Seed the catalog (optional):

    python seed_catalog.py
  5. Test endpoints:

    • Register/sign in, get a JWT, and use it for order/catalog APIs.
    • Use /api/root_cause for AI analysis.

πŸ§‘β€πŸ’» API Endpoints

Monitoring Engine

  • GET /api/health β€” System health
  • GET /api/summary β€” Metrics summary
  • GET /api/metrics β€” Detailed metrics
  • GET /api/performance β€” Performance analytics
  • GET /api/analytics β€” Analytics
  • GET /api/root_cause β€” AI root cause analysis
  • GET /api/errors/analysis β€” Error analysis
  • GET /api/logs β€” Logs
  • GET /api/services β€” Per-service metrics
  • GET /api/ollama/test β€” Ollama diagnostics

Auth Service

  • POST /register β€” Register user
  • POST /signin β€” Sign in (returns JWT)
  • GET /ping, GET /health, GET /metrics

Order Service

  • POST /api/v1/order β€” Place order (JWT)
  • GET /api/v1/orders β€” List user orders (JWT)
  • GET /ping, GET /health, GET /metrics

Catalog Service

  • 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

πŸ”’ Security

  • JWT-based authentication for all protected endpoints
  • Secure password hashing (bcrypt)
  • Service-to-service authentication
  • Environment variable configuration

πŸ“ Logging & Debugging

  • 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/*

πŸ€– AI Root Cause Analysis

  • /api/root_cause and dashboard button use Ollama LLaMA 3 for incident analysis
  • Detects error spikes, latency anomalies, service-specific issues
  • Returns actionable recommendations

πŸ§ͺ Testing

  • Controller generates traffic and errors
  • Use seed_catalog.py to add products
  • Manual API testing with curl/Postman

βš™οΈ Configuration

  • .env for secrets and DB URIs
  • docker-compose.yaml for service orchestration
  • prometheus/prometheus.yml for metrics scraping

About

Application_Performance_Monitor_Dynamic

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors