This guide shows how to integrate the monitoring stack with your existing Nova Rewards infrastructure.
Run monitoring stack separately from your application:
# Terminal 1: Start application
cd novaRewards
docker-compose up -d
# Terminal 2: Start monitoring
cd ../monitoring
docker-compose -f docker-compose.monitoring.yml up -ddocker network create nova-rewards_monitoringAdd monitoring network to your backend service:
# novaRewards/docker-compose.yml
version: "3.9"
services:
postgres:
# ... existing config ...
networks:
- default
- monitoring
backend:
# ... existing config ...
networks:
- default
- monitoring
gateway:
# ... existing config ...
networks:
- default
- monitoring
networks:
monitoring:
external: true
name: nova-rewards_monitoring# Start application
cd novaRewards
docker-compose up -d
# Start monitoring
cd ../monitoring
docker-compose -f docker-compose.monitoring.yml up -dCreate a combined setup for local development:
# Create combined compose file
cd novaRewardsCreate docker-compose.with-monitoring.yml:
version: "3.9"
services:
# Application services
postgres:
image: postgres:16-alpine
restart: unless-stopped
env_file: .env
environment:
POSTGRES_DB: ${POSTGRES_DB:-nova_rewards}
POSTGRES_USER: ${POSTGRES_USER:-nova}
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
volumes:
- postgres_data:/var/lib/postgresql/data
- ./database:/docker-entrypoint-initdb.d:ro
healthcheck:
test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER:-nova}"]
interval: 5s
timeout: 5s
retries: 10
ports:
- "5432:5432"
networks:
- default
- monitoring
backend:
build:
context: ./backend
dockerfile: Dockerfile
restart: unless-stopped
env_file: .env
environment:
PORT: 4000
NODE_ENV: ${NODE_ENV:-development}
DATABASE_URL: postgresql://${POSTGRES_USER:-nova}:${POSTGRES_PASSWORD}@postgres:5432/${POSTGRES_DB:-nova_rewards}
ports:
- "4000:4000"
depends_on:
postgres:
condition: service_healthy
networks:
- default
- monitoring
# Monitoring services
prometheus:
image: prom/prometheus:v2.48.0
restart: unless-stopped
command:
- '--config.file=/etc/prometheus/prometheus.yml'
- '--storage.tsdb.path=/prometheus'
- '--storage.tsdb.retention.time=30d'
volumes:
- ../monitoring/prometheus/prometheus.yml:/etc/prometheus/prometheus.yml:ro
- ../monitoring/prometheus/rules:/etc/prometheus/rules:ro
- prometheus_data:/prometheus
ports:
- "9090:9090"
networks:
- monitoring
grafana:
image: grafana/grafana:10.2.2
restart: unless-stopped
volumes:
- grafana_data:/var/lib/grafana
- ../monitoring/grafana/provisioning:/etc/grafana/provisioning:ro
ports:
- "3000:3000"
environment:
- GF_SECURITY_ADMIN_PASSWORD=${GRAFANA_ADMIN_PASSWORD:-admin}
networks:
- monitoring
depends_on:
- prometheus
node-exporter:
image: prom/node-exporter:v1.7.0
restart: unless-stopped
command:
- '--path.procfs=/host/proc'
- '--path.sysfs=/host/sys'
- '--path.rootfs=/rootfs'
volumes:
- /proc:/host/proc:ro
- /sys:/host/sys:ro
- /:/rootfs:ro
ports:
- "9100:9100"
networks:
- monitoring
volumes:
postgres_data:
prometheus_data:
grafana_data:
networks:
monitoring:
driver: bridgeStart everything:
docker-compose -f docker-compose.with-monitoring.yml up -dKeep both systems for comprehensive monitoring:
CloudWatch (Infrastructure):
- ALB metrics
- EC2 metrics
- Auto Scaling events
- RDS metrics (if using RDS)
Prometheus (Application):
- API metrics
- Business metrics
- Custom application metrics
Use CloudWatch exporter to send Prometheus metrics to CloudWatch:
# Add to docker-compose.monitoring.yml
cloudwatch-exporter:
image: prom/cloudwatch-exporter:latest
ports:
- "9106:9106"
volumes:
- ./cloudwatch-exporter.yml:/config/config.yml
environment:
- AWS_ACCESS_KEY_ID=${AWS_ACCESS_KEY_ID}
- AWS_SECRET_ACCESS_KEY=${AWS_SECRET_ACCESS_KEY}
- AWS_REGION=${AWS_REGION}If deploying to Kubernetes:
kubectl create namespace monitoring
helm repo add prometheus-community https://prometheus-community.github.io/helm-charts
helm install prometheus prometheus-community/kube-prometheus-stack -n monitoringapiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
name: nova-backend
namespace: monitoring
spec:
selector:
matchLabels:
app: nova-backend
endpoints:
- port: metrics
path: /metrics
interval: 15sapiVersion: v1
kind: Service
metadata:
name: nova-backend
labels:
app: nova-backend
spec:
ports:
- name: http
port: 4000
- name: metrics
port: 4000
selector:
app: nova-backend# Test backend metrics
curl http://localhost:4000/metrics
# Should see Prometheus format metrics# Open Prometheus UI
open http://localhost:9090/targets
# All targets should show "UP" status# Login to Grafana
open http://localhost:3000
# Go to Configuration > Data Sources
# Prometheus should be connected and working# Query Prometheus
curl -G 'http://localhost:9090/api/v1/query' \
--data-urlencode 'query=up{job="nova-backend"}'
# Should return result with value 1# Check if backend is exposing metrics
curl http://localhost:4000/metrics
# Check Prometheus logs
docker logs nova-prometheus
# Check network connectivity
docker exec -it nova-prometheus wget -O- http://backend:4000/metrics# Check if services are on same network
docker network inspect nova-rewards_monitoring
# Verify service names in prometheus.yml match container names
# Update prometheus.yml if needed# Test Prometheus datasource
curl http://localhost:3000/api/datasources
# Test query directly
curl -G 'http://localhost:9090/api/v1/query' \
--data-urlencode 'query=up'
# Check Grafana logs
docker logs nova-grafana┌─────────────────────────────────────────────────┐
│ Docker Network: default │
│ │
│ ┌──────────┐ ┌──────────┐ ┌──────────┐ │
│ │PostgreSQL│◄───│ Backend │◄───│ Gateway │ │
│ └──────────┘ └────┬─────┘ └──────────┘ │
│ │ │
└───────────────────────┼─────────────────────────┘
│
│ :4000/metrics
│
┌───────────────────────┼─────────────────────────┐
│ Docker Network: monitoring │
│ │ │
│ ▼ │
│ ┌──────────────┐ ┌──────────┐ ┌──────────┐ │
│ │ Prometheus │◄─│Exporters │ │ Grafana │ │
│ │ (Scraper) │ │ │ │(Dashboards)│
│ └──────┬───────┘ └──────────┘ └──────────┘ │
│ │ │
│ ▼ │
│ ┌──────────────┐ │
│ │Alertmanager │ │
│ └──────────────┘ │
└─────────────────────────────────────────────────┘
- Use External Networks: Keep monitoring separate from application
- Secure Metrics Endpoint: Add authentication in production
- Limit Scrape Frequency: Balance between freshness and load
- Set Retention Policies: Don't store metrics forever
- Monitor the Monitors: Set up meta-monitoring
- Use Service Discovery: For dynamic environments
- Implement Backups: Backup Prometheus data regularly
- Monitoring network created
- Backend connected to monitoring network
- Metrics endpoint accessible
- Prometheus scraping successfully
- Grafana dashboards working
- Alerts configured and tested
- Notification channels configured
- Runbooks reviewed by team
- Backup procedures in place
- SSL/TLS configured for Grafana
- Access controls implemented
- Documentation updated