Prometheus (metrics storage) + Grafana (visualization) — the open-source standard for monitoring. Deploy in 15 min via Docker Compose. Prometheus scrapes /metrics endpoints of your apps + Node exporter (system metrics). Grafana connects to Prometheus as a data source, shows dashboards. No lock-in: all open-source, self-hosted.
Below: step-by-step, working examples, common pitfalls, FAQ.
docker compose up -d| Scenario | Config |
|---|---|
| docker-compose.yml | services:
prometheus:
image: prom/prometheus
ports: ["9090:9090"]
volumes: [./prometheus.yml:/etc/prometheus/prometheus.yml]
grafana:
image: grafana/grafana
ports: ["3000:3000"]
environment:
- GF_SECURITY_ADMIN_PASSWORD=change_me |
| prometheus.yml | scrape_configs:
- job_name: 'node'
static_configs:
- targets: ['host.docker.internal:9100']
- job_name: 'app'
metrics_path: '/metrics'
static_configs:
- targets: ['app:8080'] |
| Node exporter | docker run -d --name node-exporter \
--net="host" --pid="host" \
-v /:/host:ro \
prom/node-exporter --path.rootfs=/host |
| PromQL query (CPU idle) | rate(node_cpu_seconds_total{mode="idle"}[5m]) |
| Alert rule | groups:
- name: example
rules:
- alert: HighCPU
expr: rate(node_cpu_seconds_total{mode!="idle"}[5m]) > 0.9
for: 5m |
Prometheus — pull model, simple setup, TSDB. InfluxDB — push model, SQL-like queries, better long-term. Prometheus wins in Kubernetes/microservices.
Default 15 days. Long-term — remote storage (Thanos, Cortex, Grafana Mimir) or Prometheus federation.
Alertmanager (separate service). Routes alerts to email, Slack, PagerDuty, Telegram.
Prometheus+Grafana — self-hosted, free. Datadog — SaaS, $15+/host/mo, better UX. Pick by budget vs control.