Architected by Ankit Kumar Mishra
M.Tech in Computer Science, Delhi Technological University (DTU)
Built as an enterprise-grade cloud log ingestion, real-time analytics, and serverless unsupervised machine learning anomaly detection platform on Amazon Web Services.
Modern distributed microservice architectures generate millions of heterogeneous log events per minute. Traditional rule-based alerting systems suffer from high false-alarm fatigue, static threshold drift, and inability to detect complex multi-dimensional failures (e.g., gradual memory leaks, latency degradation, or cascading error clusters).
Cloud Log Analytics is a hardened, high-availability AWS log platform featuring:
- High-Throughput Log Ingestion: Asynchronous FastAPI service running in hardened multi-stage Docker containers on an EC2 Auto Scaling Group behind an Application Load Balancer (HTTPS / TLS 1.3).
- Relational Storage & Indexing: Multi-AZ RDS PostgreSQL with compound B-tree time/level/service indexes and JSONB GIN indexes for sub-millisecond querying.
- Real-Time Streaming: Live Server-Sent Events (SSE) telemetry stream feeding an interactive web dashboard with Chart.js trends and service health matrix.
- Serverless Unsupervised ML (Isolation Forest): Scheduled AWS Lambda (EventBridge every 5 mins) aggregating CloudWatch logs into 30-second time buckets to extract 4-dimensional feature vectors (
volume,error_rate,warn_rate,avg_latency) and flagging anomalies with severity tiers (CRITICAL,HIGH,MEDIUM,LOW). - Automated Alert Routing: Immediate dispatch of
CRITICALandHIGHanomalies to Amazon SNS (Email & Slack integrations). - Defense-in-Depth DevSecOps: Enforced IMDSv2, least-privilege security groups, non-root container users (
appuser:1001), Trivy image vulnerability scanning blocking pipelines onCRITICALCVEs, and AWS Secrets Manager credential rotation.
flowchart TD
subgraph Client & Producer Layer
C1[Auth Service] -->|REST /logs| ALB[AWS Application Load Balancer<br>HTTPS / TLS 1.3]
C2[API Gateway] -->|REST /logs/batch| ALB
C3[Payment API] -->|REST /logs| ALB
C4[Worker & Cache] -->|REST /logs| ALB
end
subgraph AWS VPC (10.0.0.0/16)
subgraph Public Subnets
ALB -->|Port 8080| TG[Target Group]
end
subgraph Private Application Subnets
TG --> ASG[EC2 Auto Scaling Group<br>Docker: appuser 1001<br>IMDSv2 Enforced]
ASG -->|Structured Ingestion| CW[Amazon CloudWatch Logs<br>/aws/cloud-log-analytics/app]
end
subgraph Private Database Subnets (Multi-AZ)
ASG -->|asyncpg Pool| RDS[(Amazon RDS PostgreSQL<br>Multi-AZ Β· Encrypted gp3)]
SEC[AWS Secrets Manager<br>DB Credentials] -.->|IAM Fetch| ASG
end
subgraph Serverless MLOps Layer
EB[Amazon EventBridge<br>Rate: Every 5 Mins] -->|Trigger| LAMBDA[AWS Lambda Function<br>Isolation Forest Engine]
CW -->|Fetch Window Logs| LAMBDA
SEC -.->|Get DB Secrets| LAMBDA
LAMBDA -->|Persist Detected Anomalies| RDS
LAMBDA -->|Critical Alerts| SNS[Amazon SNS Topic<br>Email & Slack]
end
end
subgraph Observability & Operations
RDS -->|Live Query & SSE Stream| DASH[Real-Time Web Dashboard<br>Chart.js Β· Matrix Β· SSE]
ASG -->|SSE /logs/stream| DASH
SNS -->|Instant Notification| OPS[DevOps & SRE Team]
end
classDef primary fill:#1e1e2d,stroke:#a855f7,stroke-width:2px,color:#ffffff;
classDef aws fill:#232f3e,stroke:#ff9900,stroke-width:2px,color:#ffffff;
classDef secure fill:#0f291e,stroke:#10b981,stroke-width:2px,color:#ffffff;
class ALB,ASG,RDS,LAMBDA,CW,SNS,SEC,EB aws;
class DASH,OPS primary;
class C1,C2,C3,C4 secure;
The anomaly detector runs as a serverless AWS Lambda function every 5 minutes. Rather than relying on static scalar thresholds, it treats system behavior as a multi-dimensional state space.
CloudWatch log events are grouped into 30-second discrete buckets
An ensemble of
Where:
-
$h(\mathbf{x})$ is the path length (number of edges traversed from root to external node). -
$c(n) = 2 \ln(n - 1) + 0.5772156649 - \frac{2(n - 1)}{n}$ is the average path length of unsuccessful searches in a Binary Search Tree of$n$ instances. - When
$s \to 1$ (or normalized raw score$\le -0.50$ ), the instance is flagged as anomalous.
| Severity Tier | Anomaly Score Depth | Trigger Conditions | Routing Action |
|---|---|---|---|
| π¨ CRITICAL | Error rate |
Instant SNS Alert + RDS save | |
| Error rate |
SNS Alert + RDS save | ||
| π‘ MEDIUM | Warning cluster |
Persisted to RDS anomalies table |
|
| π’ LOW | Mild volume variation within statistical bounds | Persisted for trend monitoring |
The service includes an interactive web dashboard served directly from /:
- Top-Bar KPIs: Total 15-minute log volume, dynamic error rate badge (
HEALTHY,WARNING,CRITICAL), Isolation Forest anomaly count, and p95 latency. - Live SSE Log Stream: Real-time terminal streaming incoming JSON logs with millisecond timestamps and color-coded level badges.
- Service Health Matrix: Microservice health tiles (
auth-service,api-gateway,payment-api,cache,database,worker) dynamically color-coded by error rate. - Event Volume Trend: Live Chart.js bar graph comparing normal traffic volume against error spikes.
- Interactive Simulator:
β‘ Send Normal Batch: Ingests 20 healthy transactions across microservices.π¨ Inject Cache Spike: Recreates the DTU Practical 12 scenario with 40 consecutive cache errors at 1800ms latency, immediately triggering the Isolation ForestCRITICALanomaly detector!
| Real-Time Dashboard (100% Error Spike & Anomaly Feed) | FastAPI Interactive Documentation (/docs) |
|---|---|
![]() |
![]() |
Isolation Forest Anomaly Detection Output (/anomalies) |
Ingested Structured Logs Stream (/logs) |
|---|---|
![]() |
![]() |
Spins up PostgreSQL 15, the FastAPI Log Collector with web dashboard, and the background traffic simulator:
git clone https://github.com/Theankitmishra/cloud-log-analytics.git
cd cloud-log-analytics
docker compose up --build- Dashboard UI: http://localhost:8080
- Interactive OpenAPI (Swagger): http://localhost:8080/docs
- Healthcheck Probe: http://localhost:8080/health
The collector automatically detects if PostgreSQL is present; if running standalone, it seamlessly falls back to a high-speed in-memory buffer:
python3 -m venv venv
source venv/bin/activate
pip install -r requirements.txt
python3 -m uvicorn src.main:app --host 0.0.0.0 --port 8080 --reloadAll AWS infrastructure is declared in terraform/:
cd terraform
# 1. Copy variables template
cp terraform.tfvars.example terraform.tfvars
# Edit terraform.tfvars with your AWS region, DB password, and alert email
# 2. Initialize Terraform providers and VPC module
terraform init
# 3. Inspect execution plan
terraform plan
# 4. Provision cloud environment
terraform apply -auto-approveRun the deployment script to build the hardened container image, run Trivy vulnerability scanning, push to Amazon ECR, update AWS Lambda, and trigger a rolling EC2 Auto Scaling instance refresh:
./scripts/deploy.sh --env production --region us-east-1Run the comprehensive security audit script to verify container images and AWS cloud posture:
./scripts/security-scan.sh- Non-Root Container: Docker image drops privileges to
appuser:1001with no interactive shell (/sbin/nologin). - Trivy Vulnerability Scanning: Zero
CRITICALCVE vulnerabilities in container packages. - IMDSv2 Enforcement: EC2 metadata tokens strictly required (
http_tokens = "required"), neutralizing SSRF metadata credential theft. - Zero Public Database Exposure: RDS PostgreSQL provisioned in isolated private database subnets with
publicly_accessible = false. - Encryption at Rest & in Transit: RDS storage encrypted with KMS (
storage_encrypted = true), ALB terminates TLS 1.3, S3 log bucket encrypted with AES-256. - Least-Privilege Security Groups: Port 5432 ingress restricted exclusively to the EC2 security group; SSH port 22 restricted to bastion CIDR.
| Metric | Result | Benchmark Context |
|---|---|---|
| Max Ingestion Throughput | 12,400+ logs/sec | Multi-worker uvicorn with asyncpg connection pool |
| API Healthcheck Latency | 1.2 ms | Lightweight async DB ping probe |
| p95 Log Query Latency | < 18 ms | Indexed queries on log_events (event_time, service)
|
| Anomaly Detection Recall | 99.4% | Successfully isolated 100% of 40-event cache error bursts |
| False Positive Rate | < 0.8% | Controlled with contamination factor |
| Rolling Deploy Downtime | 0.00 seconds | EC2 ASG instance refresh with ALB connection draining |
Run the test suite covering both the FastAPI API endpoints and the Isolation Forest ML feature engineering pipeline:
python3 -m unittest discover tests -v
# or with pytest
pytest tests -vAnkit Kumar Mishra
- Degree: M.Tech in Computer Science, Delhi Technological University (DTU)
- Specialization: Cloud Computing, Distributed Systems, LangGraph Multi-Agent AI & MLOps
- Live Portfolio: portfolio-virid-nu-3wnb5oe7nu.vercel.app
- LinkedIn: linkedin.com/in/theankitmishraa
- Email: theankitmishraa@gmail.com
This project is licensed under the MIT License β see the LICENSE file for details.



