Complete observability solution implemented for Nova Rewards platform with Prometheus, Grafana, Alertmanager, and comprehensive incident response runbooks.
- ✅ Application metrics (HTTP requests, latency, errors)
- ✅ System metrics (CPU, memory, disk, network)
- ✅ Database metrics (PostgreSQL connections, queries, performance)
- ✅ Cache metrics (Redis memory, operations, hit rate)
- ✅ Business metrics (rewards, redemptions, registrations)
- ✅ Endpoint health checks (blackbox monitoring)
- ✅ Pre-configured dashboards
- ✅ Real-time metrics visualization
- ✅ Custom dashboard provisioning
- ✅ Prometheus datasource integration
- ✅ 12 critical and warning alerts configured
- ✅ Multi-channel notifications (Slack, PagerDuty, Email)
- ✅ Alert routing and grouping
- ✅ Inhibition rules to prevent alert fatigue
- ✅ 6 detailed runbooks created
- ✅ Step-by-step troubleshooting procedures
- ✅ Common causes and solutions documented
- ✅ Escalation procedures defined
- ✅ Improved metrics middleware
- ✅ Database query tracking
- ✅ Redis operation monitoring
- ✅ Business metrics instrumentation
┌──────────────────────────────────────────────────────────┐
│ Nova Rewards Backend │
│ (Exposes /metrics) │
└────────────────────────┬─────────────────────────────────┘
│
▼
┌────────────────────────────────────────────────────────────┐
│ Prometheus │
│ - Scrapes metrics every 15s │
│ - Evaluates alert rules │
│ - 30-day retention │
└────────────┬───────────────────────────┬───────────────────┘
│ │
▼ ▼
┌────────────────┐ ┌─────────────────┐
│ Grafana │ │ Alertmanager │
│ (Dashboards) │ │ (Routing) │
└────────────────┘ └────────┬────────┘
│
┌───────────────┼───────────────┐
▼ ▼ ▼
┌────────┐ ┌─────────┐ ┌────────┐
│ Slack │ │PagerDuty│ │ Email │
└────────┘ └─────────┘ └────────┘
- HighErrorRate: 5xx errors > 5% for 5 minutes
- ServiceDown: Service unreachable for 2 minutes
- PostgreSQLDown: Database unreachable for 2 minutes
- RedisDown: Cache unreachable for 2 minutes
- EndpointDown: Health check failing for 5 minutes
- HighLatency: 95th percentile > 1 second for 10 minutes
- HighCPUUsage: CPU > 80% for 10 minutes
- HighMemoryUsage: Memory > 85% for 10 minutes
- HighDatabaseConnections: Connections > 80% of max
- HighRedisMemory: Redis memory > 90%
- DiskSpaceLow: Disk space < 15%
- SSLCertificateExpiringSoon: Certificate expires in < 7 days
- high-error-rate.md - Troubleshooting 5xx errors
- service-down.md - Service outage response
- high-latency.md - Performance degradation
- postgres-down.md - Database failure recovery
- redis-down.md - Cache failure recovery
- high-cpu.md - CPU exhaustion troubleshooting
- high-memory.md - Memory leak investigation
Each runbook includes:
- Alert details and symptoms
- Investigation steps with commands
- Common causes and solutions
- Escalation procedures
- Post-incident actions
http_request_duration_seconds - Request latency histogram
http_requests_total - Total request counter
http_requests_active - Active requests gauge
db_query_duration_seconds - Database query latency
redis_operation_duration_seconds - Redis operation latency
rewards_distributed_total - Business metric
redemptions_processed_total - Business metric
user_registrations_total - Business metric
node_cpu_seconds_total - CPU usage
node_memory_MemAvailable_bytes - Available memory
node_filesystem_avail_bytes - Disk space
node_network_receive_bytes_total - Network I/O
pg_up - Database availability
pg_stat_database_numbackends - Connection count
pg_stat_database_xact_commit - Transaction rate
pg_database_size_bytes - Database size
redis_up - Redis availability
redis_memory_used_bytes - Memory usage
redis_keyspace_hits_total - Cache hits
redis_connected_clients - Connection count
cd monitoring
cp .env.example .env
# Edit .env with your configuration
./scripts/setup.sh- Grafana: http://localhost:3000 (admin/admin)
- Prometheus: http://localhost:9090
- Alertmanager: http://localhost:9093
Edit alertmanager/alertmanager.yml:
- Add Slack webhook URL
- Add PagerDuty integration key
- Configure email SMTP settings
./scripts/test-alerts.shThe backend already has prom-client installed and metrics middleware configured. Enhanced metrics are now available at /metrics endpoint.
# Connect backend to monitoring network
networks:
monitoring:
external: true
name: nova-rewards_monitoringMonitoring stack complements existing CloudWatch:
- CloudWatch: Infrastructure metrics (ALB, EC2, Auto Scaling)
- Prometheus: Application metrics (API, business logic)
prometheus/prometheus.yml- Prometheus configurationprometheus/rules/alerts.yml- Alert rulesprometheus/rules/recording-rules.yml- Recording rulesalertmanager/alertmanager.yml- Alert routingblackbox/blackbox.yml- Endpoint monitoring configgrafana/provisioning/datasources/prometheus.yml- Datasource configgrafana/provisioning/dashboards/dashboard.yml- Dashboard provisioning
docker-compose.monitoring.yml- Complete monitoring stack
README.md- Comprehensive documentationQUICK_START.md- 5-minute setup guideDEPLOYMENT.md- Production deployment guideMONITORING_SUMMARY.md- This file
runbooks/high-error-rate.mdrunbooks/service-down.mdrunbooks/high-latency.mdrunbooks/postgres-down.mdrunbooks/redis-down.mdrunbooks/high-cpu.mdrunbooks/high-memory.md
scripts/setup.sh- Automated setupscripts/test-alerts.sh- Alert testing
grafana/dashboards/nova-overview.json- Main dashboard
novaRewards/backend/middleware/metricsMiddleware.js- Enhanced metrics
- ✅ Deploy monitoring stack
- ✅ Configure Slack/PagerDuty webhooks
- ✅ Test alert notifications
- ✅ Review and customize alert thresholds
- Create custom Grafana dashboards for your team
- Set up automated backups for Prometheus data
- Configure SSL/TLS for Grafana in production
- Add more business-specific metrics
- Set up log aggregation (ELK/Loki)
- Implement distributed tracing (Jaeger/Tempo)
- Add synthetic monitoring (uptime checks)
- Set up anomaly detection
- Implement SLO/SLI tracking
- Create custom alerting rules for business metrics
- Monitor alert notifications
- Review dashboard for anomalies
- Review alert accuracy (false positives/negatives)
- Check Prometheus disk usage
- Verify backup procedures
- Update alert thresholds based on trends
- Review and update runbooks
- Conduct incident response drills
- Update dashboards
- Prometheus: https://prometheus.io/docs/
- Grafana: https://grafana.com/docs/
- Alertmanager: https://prometheus.io/docs/alerting/
- Runbooks:
monitoring/runbooks/ - Setup Guide:
monitoring/QUICK_START.md - Deployment Guide:
monitoring/DEPLOYMENT.md
- Check service logs:
docker-compose -f docker-compose.monitoring.yml logs - Verify targets: http://localhost:9090/targets
- Test queries: http://localhost:9090/graph
Track these to measure monitoring effectiveness:
- Mean Time to Detect (MTTD): < 2 minutes
- Mean Time to Resolve (MTTR): < 15 minutes for critical issues
- Alert accuracy: > 95% (low false positive rate)
- Dashboard usage: Team regularly reviews dashboards
- Runbook effectiveness: Incidents resolved using runbooks
You now have a production-ready monitoring and alerting system with:
- ✅ Comprehensive metrics collection
- ✅ Real-time visualization
- ✅ Intelligent alerting
- ✅ Detailed incident response procedures
- ✅ Integration with existing infrastructure
The system is designed to provide early warning of issues, enable quick troubleshooting, and minimize downtime.