1. 拉取依賴鏡像
docker pull prom/node-exporter
docker pull prom/prometheus
docker pull grafana/grafana
2.分別啓動各鏡像
-
啓動node-exporter
docker run -d -p 9100:9100 \ --name node-exporter \ --restart=always \ -v /opt/dockerData/node-exporter/proc:/host/proc:ro \ -v /opt/dockerData/node-exporter/sys:/host/sys:ro \ -v /opt/dockerData/node-exporter:/rootfs:ro \ prom/node-exporter
-
啓動promethus
docker run -d \ --name prometheus \ --restart=always \ -u root \ -p 9090:9090 \ -v /opt/dockerData/prometheus/prometheus.yml:/etc/prometheus/prometheus.yml \ -v /opt/dockerData/prometheus:/prometheus \ -v /opt/dockerData/prometheus/conf:/etc/prometheus/conf \ prom/prometheus
prometheus.yml
global: scrape_interval: 60s evaluation_interval: 60s scrape_configs: - job_name: prometheus static_configs: - targets: - 192.168.0.104:9090 - job_name: node-exporter static_configs: - targets: - 192.168.0.104:9100
-
啓動grafana
docker run -d \ -p 3000:3000 \ --restart=always \ --name=grafana \ -u root \ -v /opt/dockerData/grafana:/var/lib/grafana \ grafana/grafana
3.登錄grafana
默認用戶名和密碼均爲admin,登錄成功後修改默認密碼