Real-time AI-powered error monitoring and analysis dashboard
A production-ready error monitoring solution that automatically categorizes, analyzes, and detects patterns in your application errors using AI. Get instant insights with real-time streaming analysis and intelligent alerting.
- Node.js 18 or higher
- A free Google Gemini API key (Get one here)
Get up and running in 30 seconds:
# Install globally
npm install -g logintelligence
# Configure your API key
logintelligence setup
# Start the dashboard
logintelligenceThe dashboard will automatically open in your browser at http://localhost:7878
- Get a Gemini API Key (free): Visit https://ai.google.dev/ and generate an API key
- Run setup: When you run
logintelligence setup, paste your API key when prompted - Start monitoring: Run
logintelligenceto launch the dashboard
Want to see it in action? Run the error simulator:
logintelligence simulateThis will generate realistic error patterns so you can explore the dashboard features.
Once the dashboard is running, send an error from your application:
curl -X POST http://localhost:7878/api/errors \
-H "Content-Type: application/json" \
-d '{
"message": "Database connection timeout",
"stack_trace": "Error: Connection timeout\n at Database.connect...",
"source": "api-gateway",
"severity": "high"
}'Watch it appear instantly in the dashboard with AI-powered analysis!
- Real-time Error Ingestion: REST API endpoint for single or batch error submission
- AI-Powered Classification: Automatic categorization and severity assessment using Google Gemini
- Live Streaming Analysis: See AI analysis happening in real-time via WebSocket
- Pattern Detection: Automatic clustering of similar errors using Levenshtein distance
- Spike Detection: Smart alerting when error rates exceed baseline thresholds
- Time-Windowed Views: Analyze errors over 15 minutes, 1 hour, or 24 hours
- Beautiful Dashboard: Modern React UI with real-time charts and filtering
logintelligence # Start dashboard on port 7878
logintelligence setup # Configure Gemini API key
logintelligence simulate # Run error simulation demo
logintelligence ingest # Ingest errors from log files
logintelligence --help # Show all available commands
logintelligence --version # Show version number- Backend: Node.js with Express
- Real-time: Socket.io for WebSocket connections
- AI: Google Gemini API for error classification
- Frontend: React 18 with Vite
- Styling: Tailwind CSS
- Charts: Recharts
- Database: SQLite with better-sqlite3
- Validation: Zod
const axios = require('axios');
// Send error to LogIntelligence
async function reportError(error, context = {}) {
try {
await axios.post('http://localhost:7878/api/errors', {
message: error.message,
stack_trace: error.stack,
source: 'my-app',
severity: 'high',
metadata: context
});
} catch (err) {
console.error('Failed to report error:', err);
}
}
// Use in your error handling
app.use((err, req, res, next) => {
reportError(err, { url: req.url, method: req.method });
res.status(500).json({ error: 'Internal server error' });
});import requests
import traceback
def report_error(error, source="python-app"):
try:
requests.post('http://localhost:7878/api/errors', json={
'message': str(error),
'stack_trace': traceback.format_exc(),
'source': source,
'severity': 'high'
})
except Exception as e:
print(f'Failed to report error: {e}')# Send error from any language/script
curl -X POST http://localhost:7878/api/errors \
-H "Content-Type: application/json" \
-d "{
\"message\": \"$ERROR_MESSAGE\",
\"source\": \"$APP_NAME\",
\"severity\": \"high\"
}"If you see "API key not configured" errors:
# Re-run setup
logintelligence setup
# Or manually set environment variable
export GEMINI_API_KEY=your_key_here
logintelligenceIf port 7878 is taken, set a custom port:
PORT=8080 logintelligenceIf you encounter database issues:
# Remove and reinitialize database
rm -rf ~/.logintelligence/data
logintelligenceEnsure you're using Node.js 18 or higher:
node --version # Should be v18.0.0 or higherWant to contribute or run from source?
# Clone the repository
git clone https://github.com/charlesinwald/logintelligence.git
cd logintelligence
# Install dependencies
npm run setupThis will install both server and client dependencies and initialize the database.
# Copy the example env file
cp .env.example .env
# Edit .env and add your Gemini API key
nano .envRequired environment variables:
GEMINI_API_KEY=your_gemini_api_key_here
PORT=7878
NODE_ENV=development
DB_PATH=./data/errors.db# Start both server and client (recommended)
npm run dev
# Or start them separately:
npm run server:dev # Server on http://localhost:7878
npm run client:dev # Client on http://localhost:5173The dashboard will be available at http://localhost:5173
Open a new terminal and run the simulation script:
# Run comprehensive demo (recommended for first time)
npm run simulate
# Or use specific modes:
node scripts/simulate-errors.js normal # Normal error rate
node scripts/simulate-errors.js spike # Generate error spike
node scripts/simulate-errors.js pattern # Generate repeated errors
node scripts/simulate-errors.js batch 20 # Send batch of 20 errorsPOST /api/errors
Submit a single error:
{
"message": "Connection timeout: Database connection pool exhausted",
"stack_trace": "Error: Connection timeout\n at Database.connect...",
"source": "api-gateway",
"severity": "high",
"environment": "production",
"user_id": "user_12345",
"request_id": "req_abc123",
"metadata": {
"url": "/api/users",
"method": "GET"
}
}Submit a batch:
{
"errors": [
{ "message": "...", "source": "..." },
{ "message": "...", "source": "..." }
]
}GET /api/errors?limit=100
Returns recent errors with AI analysis.
GET /api/errors/stats?window=3600000
Returns error statistics for the specified time window (in milliseconds).
GET /api/errors/:id
Returns a specific error with similar errors.
GET /api/errors/range/:start/:end
Returns errors between start and end timestamps.
request:initial_data- Request initial dashboard datarequest:stats- Request updated statisticsrequest:spike_check- Check for spike detectionping- Connection health check
connection:established- Connection confirmationdata:initial- Initial errors and statserror:new- New error receivederror:ai_stream- Streaming AI analysis chunkserror:ai_complete- AI analysis completealert:spike- Spike detecteddata:stats_update- Periodic stats update (every 30s)
βββββββββββββββββββ
β React Client β β WebSocket (Socket.io)
β (Port 5173) β
ββββββββββ¬βββββββββ
β HTTP/WS
β
βββββββββββββββββββ
β Express Server β β REST API + WebSocket
β (Port 7878) β
ββββββββββ¬βββββββββ
β
ββββββ΄βββββ¬βββββββββββ
β β β
ββββββββββ ββββββββ βββββββββββ
β SQLite β βGeminiβ βSocket.ioβ
β (WAL) β β AI β β Events β
ββββββββββ ββββββββ βββββββββββ
- Streaming AI Responses: AI analysis streams through Socket.io as it's generated
- Time-Bucketed Stats: 5-minute buckets for efficient spike detection
- Pattern Hashing: MD5 hashes of normalized errors for deduplication
- Connection Pooling: SQLite WAL mode for concurrent read/write
- Real-time Updates: All clients receive updates via WebSocket broadcasts
Stores all incoming error events with AI analysis results.
Tracks recurring error patterns with occurrence counts.
Time-series aggregation in 5-minute buckets for spike detection.
- Live-updating error stream
- Expandable error cards with full stack traces
- Severity filtering
- Real-time AI analysis streaming
- Color-coded severity badges
- Bar chart showing error distribution by category
- Top 10 categories
- Dynamic color coding
- Prominent alerts when error rates spike
- Shows current rate vs baseline
- Dismissible notifications
- Total errors
- Error rate (per minute)
- Category count
- Active errors in memory
error-intelligence/
βββ server/
β βββ index.js # Express + Socket.io setup
β βββ routes/
β β βββ errors.js # Error ingestion endpoints
β βββ services/
β β βββ ai.js # Gemini API integration
β β βββ patterns.js # Pattern detection & spike detection
β βββ db/
β β βββ index.js # SQLite setup with prepared statements
β β βββ schema.sql # Database schema
β βββ socket/
β βββ handler.js # WebSocket event handlers
βββ client/
β βββ src/
β β βββ App.jsx
β β βββ components/
β β β βββ Dashboard.jsx
β β β βββ ErrorFeed.jsx
β β β βββ CategoryChart.jsx
β β β βββ SpikeAlert.jsx
β β βββ hooks/
β β β βββ useSocket.js
β β βββ utils/
β β βββ formatters.js
β βββ index.html
βββ scripts/
β βββ simulate-errors.js # Error simulation for demo
β βββ setup-db.js # Database initialization
βββ package.json
# Start the server
npm run server:dev
# In another terminal, run simulations
npm run simulate# Build the client
npm run build
# Start production server
NODE_ENV=production npm startThe server will serve the built client from client/dist/.
- Set
NODE_ENV=production - Configure
FRONTEND_URLfor CORS in production - Secure your
GEMINI_API_KEY
- SQLite works well for MVP/demo purposes
- For production scale, consider PostgreSQL or MongoDB
- Current implementation supports thousands of errors efficiently
- Add Redis for Socket.io adapter (multi-server support)
- Implement rate limiting on API endpoints
- Add authentication for dashboard access
- Set up reverse proxy (nginx) for production
The spike detection algorithm works as follows:
- Errors are bucketed into 5-minute time windows
- Current bucket error count is compared to hourly average
- Spike is triggered when current rate exceeds 2x baseline
- Spikes are calculated per source/category combination
- Alerts are broadcast to all connected clients
- Webhook notifications for critical spikes
- Error deduplication with fingerprinting
- User authentication and authorization
- Export errors to CSV/JSON
- Email alerts for critical errors
- Error resolution workflow
- Integration with Slack/PagerDuty
- Advanced analytics and trends
- Custom alerting rules
- Multi-tenant support
This is a portfolio/demo project. Feel free to fork and adapt for your own use!
MIT License - feel free to use this code for your own projects.
- Built with Gemini AI for intelligent error classification
- UI components styled with Tailwind CSS
- Charts powered by Recharts
- Real-time communication via Socket.io
Built with β€οΈ as a weekend MVP to showcase modern full-stack development patterns.