A distributed log aggregation system similar to Splunk/Datadog, built with C++, TypeScript, and Python.
- High-throughput log collection - C++ agent tails log files and batches entries
- Custom message queue - Persistent queue for reliable log delivery
- Full-text search - SQLite FTS5 for fast log queries
- ML anomaly detection - Python service with Isolation Forest
- Real-time dashboard - Next.js frontend with observability UI
| Component | Technology |
|---|---|
| Log Agent | C++17, Winsock |
| Message Queue | C++17, Thread Pool |
| API Server | TypeScript, Node.js, Express |
| Storage | SQLite + FTS5 |
| Anomaly Detection | Python, FastAPI, scikit-learn |
| Frontend | Next.js 15, React, Tailwind CSS |
| Deployment | Docker Compose |
- C++17 compiler (MSVC on Windows)
- CMake 3.16+
- Node.js 20+
- Python 3.11+
- Docker Desktop (optional, for containerized deployment)
Full local development stack:
test-local.batStarts API, anomaly service, and frontend locally with health checks.
Start services individually:
start-local.bat # Start all services in background
stop-local.bat # Stop all running servicesFull Docker stack:
test-docker.batBuilds and starts all containers with health checks.
cd docker
docker-compose up --buildServices:
- Frontend: http://localhost:3001
- API: http://localhost:3000
- Anomaly: http://localhost:8000
- Queue: http://localhost:8080
C++ Agent:
cd agent && mkdir -p build && cd build && cmake .. && cmake --build . --config Debug
./Debug/log_agent.exe --file test.log --queue-host localhost --queue-port 8080C++ Queue:
cd queue && mkdir -p build && cd build && cmake .. && cmake --build . --config Debug
./Debug/log_queue.exe --port 8080 --db ./data/queue.dbTypeScript API:
cd api && npm install && npm run devPython Anomaly Detection:
cd anomaly
python -m venv venv
venv\Scripts\activate
pip install -r requirements.txt
python -m src.mainNext.js Frontend:
cd frontend && npm install && npm run dev| Script | Purpose |
|---|---|
test-local.bat |
Start local dev stack with health checks |
test-docker.bat |
Start Docker stack with health checks |
start-local.bat |
Start services in background |
stop-local.bat |
Stop all running services |
api/scripts/seed.ts |
Generate dummy log/alert data |
cd api
npm test # All tests
npm test -- logs.test.ts # Single file
npm test -- --testNamePattern="logs" # Pattern matchcd anomaly
venv\Scripts\activate
pytest # All tests
pytest -v # Verbose outputcd queue/build/Debug
mkdir -p data
./log_queue.exe --port 8080 --db ./data/queue.db &
curl -X POST http://localhost:8080/api/logs/batch \
-H "Content-Type: application/json" \
-d "[\"log1\",\"log2\",\"log3\"]"
curl http://localhost:8080/api/logs/pending| Method | Endpoint | Description |
|---|---|---|
| POST | /api/logs |
Ingest single log |
| POST | /api/logs/batch |
Ingest log batch |
| GET | /api/logs |
Search logs with filters |
| GET | /api/logs/stats |
Get log statistics |
Query Parameters (GET /api/logs):
q- Full-text search querylevel- Filter by log level (ERROR, WARN, INFO, DEBUG)source- Filter by sourcestart/end- Time range (ISO 8601)limit/offset- Pagination
| Method | Endpoint | Description |
|---|---|---|
| GET | /api/alerts |
List alerts |
| GET | /api/alerts/:id |
Get single alert |
| PUT | /api/alerts/:id/acknowledge |
Acknowledge alert |
| Method | Endpoint | Description |
|---|---|---|
| GET | /health |
Service health check |
| GET | /status |
Detector status and metrics |
| POST | /detect |
Trigger manual detection |
┌─────────────┐ ┌──────────────┐ ┌─────────────────┐
│ Log Agent │────▶│ C++ Queue │────▶│ Node.js API │
│ (C++) │ │ (Custom) │ │ (TypeScript) │
└─────────────┘ └──────────────┘ └─────────────────┘
│
┌─────────────────────┼─────────────────────┐
▼ ▼ ▼
┌─────────────┐ ┌─────────────┐ ┌─────────────┐
│ SQLite │ │ Python │ │ Frontend │
│ + FTS5 │ │ Anomaly │ │ (Next.js) │
└─────────────┘ └─────────────┘ └─────────────┘
Data Flow:
- Agent tails log files and sends batches to Queue
- Queue persists logs and exposes HTTP API
- API consumer polls Queue and writes to SQLite with FTS5
- Anomaly service reads logs, detects anomalies, writes alerts
- Frontend displays logs, stats, and alerts in real-time
PORT=3000
QUEUE_HOST=localhost
QUEUE_PORT=8080
DB_PATH=./data/logs.db
POLL_INTERVAL_MS=1000
API_BASE_URL=http://localhost:3000
DB_PATH=./data/logs.db
POLL_INTERVAL_SECONDS=30
NEXT_PUBLIC_API_URL=http://localhost:3000
# API
cd api && npm run lint
# Frontend
cd frontend && npm run lint
# Python
cd anomaly && black src/ && flake8 src/MIT