Prometheus scrapes metrics over HTTP; Grafana draws them.
version: "3.8"
services:
prometheus:
image: prom/prometheus:v2.25.0
volumes: ["./prometheus.yml:/etc/prometheus/prometheus.yml:ro"]
ports: ["9090:9090"]
node:
image: prom/node-exporter:v1.1.0
pid: host
volumes: ["/:/host:ro,rslave"]
command: ["--path.rootfs=/host"]
grafana:
image: grafana/grafana:7.4.2
ports: ["3000:3000"]
volumes: ["grafdata:/var/lib/grafana"]
volumes:
grafdata:
prometheus.yml:
scrape_configs:
- job_name: node
static_configs:
- targets: ["node:9100"]
Start with docker-compose up -d. In Grafana (login admin, then change the password) add Prometheus as a data source at http://prometheus:9090 and import community dashboard 1860 (Node Exporter Full). Keep ports private or put them behind a reverse proxy with authentication.