Why Monitoring Matters
Without monitoring, you find out about problems when your users report them. With monitoring, you find out before users notice — or better yet, your alerts wake you up at 3 AM instead of your users flooding support at 9 AM. Prometheus + Grafana is the industry standard stack for this, and it's free.
The Stack
- Prometheus — collects and stores metrics (CPU, memory, requests per second, error rates)
- Node Exporter — exposes Linux server metrics to Prometheus
- Grafana — visualizes metrics in beautiful dashboards with alerting
Step 1: docker-compose.yml
version: '3.8'
services:
prometheus:
image: prom/prometheus:latest
volumes:
- ./prometheus.yml:/etc/prometheus/prometheus.yml
ports:
- "9090:9090"
node_exporter:
image: prom/node-exporter:latest
ports:
- "9100:9100"
grafana:
image: grafana/grafana:latest
ports:
- "3000:3000"
environment:
- GF_SECURITY_ADMIN_PASSWORD=your_password
Step 2: prometheus.yml
global:
scrape_interval: 15s
scrape_configs:
- job_name: 'node'
static_configs:
- targets: ['node_exporter:9100']
Step 3: Import Dashboard
Start everything with docker compose up -d, open Grafana at http://your-server:3000, add Prometheus as a data source, then import dashboard ID 1860 (Node Exporter Full) from Grafana's dashboard library. You'll have CPU, memory, disk, and network graphs in 2 minutes.
Step 4: Set Up Alerts
In Grafana, create an alert for CPU > 80% for 5 minutes. Add a notification channel (email, Telegram, Slack) and you'll get notified before things get critical.
Need monitoring set up for your production environment? I can help.