jaisuriya153/-Real-Time-Cloud-Log-Monitoring-Incident-Response-System

GitHub: jaisuriya153/-Real-Time-Cloud-Log-Monitoring-Incident-Response-System

Stars: 0 | Forks: 0

# 🔍 Real-Time Cloud Log Monitoring & Incident Response System A simple, full-stack web application for real-time cloud log monitoring and incident response management. ## 🎯 Features - 👤 **User Authentication** - Login/Register with JWT - 📊 **Real-Time Logs** - WebSocket-based live log streaming - ⚠️ **Error Detection** - Automatic error and critical log detection - 🚨 **Incident Management** - Create, track, and resolve incidents - 📈 **Dashboard** - Visual analytics with charts and statistics - 🔔 **Real-Time Alerts** - Instant notifications for critical events ## 🛠️ Tech Stack ### Backend - **Node.js + Express** - RESTful API server - **Socket.io** - Real-time WebSocket communication - **MongoDB** - Document database - **JWT** - Authentication tokens - **bcryptjs** - Password hashing ### Frontend - **React.js** - UI library - **Socket.io Client** - Real-time client - **Axios** - HTTP client - **Chart.js** - Data visualization - **CSS3** - Styling ## 📁 Project Structure cloud computing/ ├── backend/ │ ├── models/ │ │ ├── User.js │ │ ├── Log.js │ │ └── Incident.js │ ├── routes/ │ │ ├── auth.js │ │ ├── logs.js │ │ └── incidents.js │ ├── middleware/ │ │ └── auth.js │ ├── server.js │ ├── seed.js │ ├── package.json │ └── .env ├── frontend/ │ ├── src/ │ │ ├── components/ │ │ │ ├── Auth.js │ │ │ ├── Dashboard.js │ │ │ ├── Logs.js │ │ │ └── Incidents.js │ │ ├── services/ │ │ │ ├── api.js │ │ │ └── socket.js │ │ ├── App.js │ │ ├── index.js │ │ └── index.css │ ├── public/ │ │ └── index.html │ ├── package.json │ └── .gitignore └── README.md ## 🚀 Quick Start ### Prerequisites - Node.js (v14+) - MongoDB (local or Atlas) - npm or yarn ### Installation #### 1. Clone and Setup Backend cd "cloud computing/backend" npm install #### 2. Configure Backend Edit `.env` file: PORT=5000 MONGODB_URI=mongodb://localhost:27017/log-monitoring JWT_SECRET=your_jwt_secret_key_keep_it_safe_12345 NODE_ENV=development #### 3. Seed Sample Data npm run seed **Expected output:** Connected to MongoDB Test user created: [user_id] 10 sample logs created Sample incidents created ✅ Database seeded successfully! Test User: testuser / test@example.com / password123 #### 4. Start Backend Server npm start The server will run on `http://localhost:5000` #### 5. Setup Frontend cd "../frontend" npm install #### 6. Start Frontend npm start React app will open at `http://localhost:3000` ## 🔐 Demo Credentials After seeding, use: - **Email:** test@example.com - **Password:** password123 ## 📊 Modules & Features ### 1. **Log Collection** - Collect logs in real-time - Support for multiple services - Different log levels: info, warning, error, critical ### 2. **Log Storage** - MongoDB for persistent storage - Indexed queries for fast retrieval - Metadata support for rich logging ### 3. **Error Detection** - Automatic incident creation on error/critical logs - Error tracking and correlation - Severity classification ### 4. **Incident & Alert** - Real-time incident notifications via WebSocket - Status tracking: Open → In Progress → Resolved - Error count tracking - Timestamp tracking ### 5. **Dashboard** - Real-time statistics - Log distribution charts - Incident overview - Welcome message with user info ## 🔌 API Endpoints ### Authentication - `POST /api/auth/register` - Register new user - `POST /api/auth/login` - Login user ### Logs (Protected) - `GET /api/logs` - Get all logs - `GET /api/logs/level/:level` - Get logs by level - `GET /api/logs/stats/summary` - Get today's statistics ### Incidents (Protected) - `GET /api/incidents` - Get all incidents - `GET /api/incidents/status/:status` - Filter by status - `POST /api/incidents` - Create incident - `PUT /api/incidents/:id` - Update incident status ## 🔌 WebSocket Events ### Client → Server - `join` - Join user room - `submit-log` - Submit new log - `request-logs` - Request logs data ### Server → Client - `new-log` - New log received - `new-incident` - New incident created - `logs-data` - Logs data response - `error` - Error message ## 📝 Sample Log Data The seed script creates: - 10 sample logs with different levels and services - 3 sample incidents with various statuses - 1 test user ## 🎨 UI Components ### Pages 1. **Login/Register** - Authentication page 2. **Dashboard** - Stats and charts 3. **Logs View** - Real-time log stream with filtering 4. **Incidents View** - Incident management with status updates ### Features - Dark-friendly design - Responsive layout - Real-time updates - Status indicators - Quick action buttons ## ⚙️ Configuration ### Backend MongoDB Connection **Local MongoDB:** mongodb://localhost:27017/log-monitoring **MongoDB Atlas (Cloud):** mongodb+srv://username:password@cluster.mongodb.net/log-monitoring Update in `.env` MONGODB_URI accordingly. ## 🐛 Troubleshooting ### Backend won't start - Check if MongoDB is running: `mongod` - Verify PORT 5000 is not in use - Check `.env` file configuration ### Frontend won't connect - Ensure backend is running on port 5000 - Check CORS settings in server.js - Clear browser cache and reload ### Database connection error - Verify MongoDB connection string - Check MongoDB service is running - Verify network access for Atlas ### Socket.io not working - Check browser console for errors - Verify socket URL in frontend - Ensure backend has CORS configured ## 📚 Development ### Add New Model 1. Create file in `backend/models/` 2. Define schema and export model 3. Use in routes with `require()` ### Add New Route 1. Create file in `backend/routes/` 2. Import models and middleware 3. Add to `server.js` with `app.use()` ### Add New Component 1. Create in `frontend/src/components/` 2. Import in `App.js` 3. Add navigation button in navbar ## 🚀 Deployment (Optional) ### Deploy Backend to Heroku cd backend heroku create your-app-name git push heroku main ### Deploy Frontend to Netlify cd frontend npm run build # Deploy build/ folder to Netlify ## 📄 License This project is open source and available under MIT license. **Built with ❤️ for easy cloud log monitoring**