ETL Monitoring Stack Deployment Guide
This guide walks you through deploying the ETL monitoring stack on a DigitalOcean droplet with Cloudflare tunnel for secure domain access.
๐ฏ Overviewโ
The monitoring stack includes:
- Grafana: Dashboard visualization
- Prometheus: Metrics collection and storage
- Alertmanager: Alert routing and notification
- Cloudflare Tunnel: Secure domain access without opening ports
๐ Step 1: Create DigitalOcean Dropletโ
Droplet Specificationsโ
- Size: Basic plan, $6/month (1GB RAM, 1 vCPU, 25GB SSD)
- Region: Choose closest to your users
- Image: Ubuntu 22.04 LTS
- Authentication: SSH key (recommended) or password
Create Dropletโ
- Go to DigitalOcean Console
- Click "Create" โ "Droplets"
- Choose Ubuntu 22.04 LTS
- Select Basic plan ($6/month)
- Choose datacenter region
- Add SSH key or set password
- Click "Create Droplet"
Get Droplet IPโ
Once created, note the public IP address (e.g., 164.92.123.456)
๐ง Step 2: Deploy Monitoring Stackโ
Prerequisitesโ
- SSH access to your droplet
- Your droplet's public IP address
Deploy the Stackโ
# Set your droplet IP
export DROPLET_IP=your_droplet_ip_here
# Deploy monitoring stack
./scripts/deploy-monitoring-droplet.sh
This script will:
- Install Docker and Docker Compose
- Set up Cloudflare tunnel
- Deploy the monitoring stack
- Configure all services
- Provide you with access URLs
Expected Outputโ
After deployment, you'll see URLs like:
Cloudflare Tunnel URLs:
Grafana: https://grafana.abc123.trycloudflare.com
Prometheus: https://prometheus.abc123.trycloudflare.com
Alertmanager: https://alertmanager.abc123.trycloudflare.com
๐ Step 3: Configure ETL Serviceโ
Update ETL Configurationโ
# Update ETL service to point to monitoring droplet
./scripts/update-etl-config.sh
Start ETL Service with Monitoringโ
# Start ETL service with monitoring enabled
./scripts/start-etl-with-monitoring.sh
๐งช Step 4: Test the Setupโ
Run Testsโ
# Test the complete monitoring setup
./scripts/test-monitoring-setup.sh
Manual Verificationโ
-
Access Grafana: Visit your Cloudflare URL
- Default credentials:
admin/admin - Change password on first login
- Default credentials:
-
Check Prometheus: Visit Prometheus URL
- Go to Status โ Targets
- Verify ETL service target is "UP"
-
View Dashboard: In Grafana
- Navigate to Dashboards
- Find "ETL System Health - Assigned Purchase Monitoring"
๐ Security Configurationโ
Change Default Passwordsโ
# SSH to your droplet
ssh root@your_droplet_ip
# Change Grafana admin password
# (Do this through Grafana UI)
# Secure the droplet
ufw enable
ufw allow ssh
ufw allow 80
ufw allow 443
Cloudflare Tunnel Securityโ
- No open ports: Cloudflare tunnel doesn't require opening ports
- End-to-end encryption: All traffic is encrypted
- Access control: You can add authentication later
๐ Accessing Your Monitoringโ
Primary URLsโ
- Grafana Dashboard:
https://grafana.your-tunnel-id.trycloudflare.com - Prometheus:
https://prometheus.your-tunnel-id.trycloudflare.com - Alertmanager:
https://alertmanager.your-tunnel-id.trycloudflare.com
Alternative Access Methodsโ
Option 1: Custom Domain (Recommended)โ
If you have a domain:
- Point your domain to Cloudflare
- Create CNAME records:
monitoring.yourdomain.com โ grafana.your-tunnel-id.trycloudflare.com
prometheus.yourdomain.com โ prometheus.your-tunnel-id.trycloudflare.com - Update Cloudflare tunnel config with custom hostnames
Option 2: Ngrok (Alternative)โ
# Install ngrok on droplet
curl -s https://ngrok-agent.s3.amazonaws.com/ngrok.install.sh | bash
# Create tunnels
ngrok http 3000 --subdomain=your-grafana
ngrok http 9090 --subdomain=your-prometheus
Option 3: Direct IP Access (Not Recommended)โ
# Open ports on droplet (less secure)
ufw allow 3000 # Grafana
ufw allow 9090 # Prometheus
ufw allow 9093 # Alertmanager
๐ง Management Commandsโ
SSH to Dropletโ
ssh root@your_droplet_ip
View Service Logsโ
# View all logs
docker-compose -f /opt/monitoring-stack/docker-compose.monitoring.yml logs -f
# View specific service logs
docker-compose -f /opt/monitoring-stack/docker-compose.monitoring.yml logs -f grafana
docker-compose -f /opt/monitoring-stack/docker-compose.monitoring.yml logs -f prometheus
Restart Servicesโ
# Restart all services
docker-compose -f /opt/monitoring-stack/docker-compose.monitoring.yml restart
# Restart specific service
docker-compose -f /opt/monitoring-stack/docker-compose.monitoring.yml restart grafana
Update Configurationโ
# Edit Prometheus config
nano /opt/monitoring-stack/prometheus.yml
# Reload Prometheus
docker-compose -f /opt/monitoring-stack/docker-compose.monitoring.yml restart prometheus
๐ Monitoring Your Monitoringโ
System Resourcesโ
# Check system resources
htop
df -h
free -h
# Monitor Docker containers
docker stats
Service Healthโ
# Check service health
curl http://localhost:3000/api/health # Grafana
curl http://localhost:9090/-/healthy # Prometheus
curl http://localhost:9093/-/healthy # Alertmanager
๐ Alerting Configurationโ
Note: All alerting is now managed in Grafana. Prometheus no longer loads alert rules from etl-alerts.yml.
Configure Slack Notificationsโ
- Create Slack webhook
- Update Alertmanager config:
nano /opt/monitoring-stack/grafana/provisioning/alerting/alertmanager.yml - Replace
YOUR_SLACK_WEBHOOK_URLwith your actual webhook - Restart Alertmanager:
docker-compose -f /opt/monitoring-stack/docker-compose.monitoring.yml restart alertmanager
Test Alertsโ
# Generate test metrics to trigger alerts
node scripts/test-metrics.js
๐ฐ Cost Breakdownโ
Monthly Costsโ
- DigitalOcean Droplet: $6/month
- Cloudflare Tunnel: Free
- Domain (optional): $1-15/year
- Total: ~$6/month
Cost Optimizationโ
- Droplet size: Start with $6/month, scale up if needed
- Storage: 25GB included, sufficient for months of metrics
- Bandwidth: 1TB included, more than enough for monitoring
๐จ Troubleshootingโ
Common Issuesโ
Services Not Startingโ
# Check Docker status
systemctl status docker
# Check container logs
docker-compose -f /opt/monitoring-stack/docker-compose.monitoring.yml logs
Cloudflare Tunnel Not Workingโ
# Check tunnel status
cloudflared tunnel list
# Check tunnel logs
journalctl -u cloudflared -f
# Restart tunnel
systemctl restart cloudflared
ETL Service Not Reachableโ
# Check if ETL service is running
curl http://your_etl_ip:3001/metrics
# Check firewall
ufw status
# Test connectivity
telnet your_etl_ip 3001
Prometheus Targets Downโ
- Check ETL service is running
- Verify network connectivity
- Check Prometheus configuration
- View target status in Prometheus UI
Getting Helpโ
- Logs: Check service logs for error messages
- Health checks: Use the provided health check endpoints
- Documentation: Refer to this guide and the README files
๐ Backup and Recoveryโ
Backup Configurationโ
# Backup all configs
tar -czf monitoring-backup-$(date +%Y%m%d).tar.gz /opt/monitoring-stack/
Restore Configurationโ
# Extract backup
tar -xzf monitoring-backup-YYYYMMDD.tar.gz -C /
# Restart services
docker-compose -f /opt/monitoring-stack/docker-compose.monitoring.yml restart
๐ Success!โ
Your monitoring stack is now deployed and ready to monitor your ETL service. You have:
โ
Secure access via Cloudflare tunnel
โ
Comprehensive dashboards for ETL health
โ
Alerting system for proactive monitoring
โ
Cost-effective solution at ~$6/month
โ
Full control over your monitoring infrastructure
The dashboard will show you real-time insights into your assigned purchase processing pipeline, helping you maintain high availability and performance.