A comprehensive monitoring and alerting system has been implemented for the Nova Rewards platform.
monitoring/
├── README.md # Main documentation
├── QUICK_START.md # 5-minute setup guide
├── DEPLOYMENT.md # Production deployment guide
├── INTEGRATION_GUIDE.md # Integration instructions
├── MONITORING_SUMMARY.md # Implementation summary
├── .env.example # Environment template
├── .gitignore # Git ignore rules
├── docker-compose.monitoring.yml # Monitoring stack
│
├── prometheus/
│ ├── prometheus.yml # Prometheus config
│ └── rules/
│ ├── alerts.yml # 12 alert rules
│ └── recording-rules.yml # Performance optimizations
│
├── alertmanager/
│ └── alertmanager.yml # Alert routing config
│
├── grafana/
│ ├── provisioning/
│ │ ├── datasources/
│ │ │ └── prometheus.yml # Datasource config
│ │ └── dashboards/
│ │ └── dashboard.yml # Dashboard provisioning
│ └── dashboards/
│ └── nova-overview.json # Main dashboard
│
├── blackbox/
│ └── blackbox.yml # Endpoint monitoring
│
├── runbooks/
│ ├── high-error-rate.md # 5xx error troubleshooting
│ ├── service-down.md # Service outage response
│ ├── high-latency.md # Performance issues
│ ├── postgres-down.md # Database recovery
│ ├── redis-down.md # Cache recovery
│ ├── high-cpu.md # CPU troubleshooting
│ └── high-memory.md # Memory leak investigation
│
└── scripts/
├── setup.sh # Automated setup
└── test-alerts.sh # Alert testing
novaRewards/backend/middleware/
└── metricsMiddleware.js # Enhanced metrics collection
cd monitoring
cp .env.example .env
# Edit .env with your configuration# Create network
docker network create nova-rewards_monitoring
# Start monitoring stack
docker-compose -f docker-compose.monitoring.yml up -d- Grafana: http://localhost:3000 (admin/admin)
- Prometheus: http://localhost:9090
- Alertmanager: http://localhost:9093
- Metrics collection and storage
- 15-second scrape interval
- 30-day retention
- Alert rule evaluation
- Real-time dashboards
- Visualization
- Pre-configured datasources
- Custom dashboard support
- Alert routing
- Notification management
- Alert grouping and inhibition
- Multi-channel notifications
- Node Exporter (9100): System metrics
- PostgreSQL Exporter (9187): Database metrics
- Redis Exporter (9121): Cache metrics
- Nginx Exporter (9113): Web server metrics
- Blackbox Exporter (9115): Endpoint health
- HighErrorRate - 5xx > 5% for 5min
- ServiceDown - Service unreachable 2min
- PostgreSQLDown - DB unreachable 2min
- RedisDown - Cache unreachable 2min
- EndpointDown - Health check failing 5min
- HighLatency - p95 > 1s for 10min
- HighCPUUsage - CPU > 80% for 10min
- HighMemoryUsage - Memory > 85% for 10min
- HighDatabaseConnections - Connections > 80%
- HighRedisMemory - Redis memory > 90%
- DiskSpaceLow - Disk < 15%
- SSLCertificateExpiringSoon - Cert expires < 7 days
Each runbook includes:
- Alert details and symptoms
- Step-by-step investigation
- Common causes and solutions
- Escalation procedures
- Post-incident actions
- high-error-rate.md - 5xx error troubleshooting
- service-down.md - Complete service outage
- high-latency.md - Performance degradation
- postgres-down.md - Database failure recovery
- redis-down.md - Cache failure recovery
- high-cpu.md - CPU exhaustion
- high-memory.md - Memory leak investigation
- HTTP request duration (histogram)
- Request rate by endpoint
- Error rate by status code
- Active requests
- Database query duration
- Redis operation duration
- Business metrics (rewards, redemptions, registrations)
- CPU usage
- Memory usage
- Disk space
- Network I/O
- Connection count
- Query performance
- Transaction rate
- Database size
- Memory usage
- Hit/miss rate
- Eviction rate
- Connection count
GRAFANA_ADMIN_PASSWORD=your-secure-password
POSTGRES_PASSWORD=your-postgres-password
SLACK_WEBHOOK_URL=https://hooks.slack.com/services/YOUR/WEBHOOK
PAGERDUTY_SERVICE_KEY=your-pagerduty-keyEdit alertmanager/alertmanager.yml:
- Slack webhook URL
- PagerDuty integration key
- Email SMTP settings
Edit prometheus/rules/alerts.yml to adjust:
- Error rate thresholds
- Latency thresholds
- Resource usage thresholds
Update novaRewards/docker-compose.yml:
services:
backend:
networks:
- default
- monitoring
networks:
monitoring:
external: true
name: nova-rewards_monitoringSee monitoring/INTEGRATION_GUIDE.md for detailed integration options.
docker-compose -f docker-compose.monitoring.yml ps
# All services should be "Up"curl http://localhost:4000/metrics
# Should return Prometheus format metricsopen http://localhost:9090/targets
# All targets should show "UP"cd monitoring
./scripts/test-alerts.sh
# Check Slack/PagerDuty for test alert- README.md - Comprehensive documentation
- QUICK_START.md - 5-minute setup guide
- DEPLOYMENT.md - Production deployment
- INTEGRATION_GUIDE.md - Integration options
- MONITORING_SUMMARY.md - Implementation details
- Deploy monitoring stack
- Configure notification channels
- Test alerts
- Review runbooks with team
- Customize Grafana dashboards
- Adjust alert thresholds
- Set up automated backups
- Configure SSL for Grafana
- Add distributed tracing
- Implement log aggregation
- Set up synthetic monitoring
- Create SLO/SLI tracking
- Main docs:
monitoring/README.md - Quick start:
monitoring/QUICK_START.md - Integration:
monitoring/INTEGRATION_GUIDE.md
# Check logs
docker-compose -f docker-compose.monitoring.yml logs
# Restart services
docker-compose -f docker-compose.monitoring.yml restart
# View Prometheus targets
curl http://localhost:9090/api/v1/targets- No metrics: Check backend is exposing /metrics endpoint
- Alerts not firing: Verify Alertmanager configuration
- Grafana no data: Check Prometheus datasource connection
- ✅ All monitoring services running
- ✅ Prometheus scraping metrics successfully
- ✅ Grafana dashboards showing data
- ✅ Alerts configured and tested
- ✅ Notification channels working
- ✅ Runbooks reviewed by team
- ✅ Integration with backend complete
For critical issues:
- Check relevant runbook in
monitoring/runbooks/ - Follow investigation steps
- Escalate per runbook procedures
- Document incident for post-mortem
Implementation Status: ✅ Complete Last Updated: 2024 Maintained By: DevOps Team