A log ingestion and analytics microservice built using Django, Kafka, and MongoDB.
This project simulates a real-world observability pipeline similar to ELK or Datadog.
Client → Django API → Kafka → Consumer → MongoDB → APIs
- Django REST Framework
- Apache Kafka
- MongoDB
- Docker (optional)
- Python
- Log ingestion (single & bulk)
- Asynchronous processing using Kafka
- MongoDB storage (flexible schema)
- Log search API
- Basic alerting (error threshold)
- Simple analytics (stats API)
- POST /api/logs
- GET /api/logs/list
- GET /api/logs/search?q=
- GET /api/alerts
- GET /api/stats
Start all services:
docker-compose up --build
Access:
- API: http://127.0.0.1:8000
- MongoDB: mongodb://localhost:27018
cd kafka_2.13-4.2.0
# Run only first time
bin/kafka-storage.sh random-uuid
bin/kafka-storage.sh format -t <UUID> -c config/server.properties
bin/kafka-server-start.sh config/server.properties
python event_stream/consumer.py
python manage.py runserver
{
"service_name": "auth-service",
"level": "ERROR",
"message": "Invalid credentials",
"timestamp": "2026-03-18T18:10:00Z",
"metadata": {
"user_id": 101
}
}
- Logs are sent to Django API
- API pushes logs to Kafka
- Consumer reads logs in batches
- Logs are stored in MongoDB
- APIs fetch logs and analytics
- Timestamps are stored in UTC
- MongoDB is used for flexible log schema
- Kafka enables scalable log processing
Shivam
LinkedIn: https://www.linkedin.com/in/programmer-shivam/
GitHub: https://github.com/shane-Coder