1、运行Node Exporter
docker run -d -p 9100:9100 \
-v "/proc:/host/proc" \
-v "/sys:/host/sys" \
-v "/:/rootfs" \
--net=host \
prom/node-exporter \
--path.procfs /host/proc \
--path.sysfs /host/sys \
--collector.filesystem.ignored-mount-points "^/(sys|proc|dev|host|etc)($|/)"
2、运行cAdvisor
docker run -d -p 8080:8080 --network host --name cadvisor -v /:/rootfs:ro -v /var/run:/var/run:rw -v /sys:/sys:ro -v /var/lib/docker/:/var/lib/docker:ro google/cadvisor:latest
3、运行Prometheus Server
新建并配置prometheus.yml文件
docker run -it -p 9090:9090 -v /root/prometheus/prometheus.yml:/etc/prometheus/prometheus.yml --name prometheus --network host prom/Prometheus
点击菜单status-->targets
4、运行grafana
docker run -id -p 3000:3000 --name grafana --network host -e "GF_SERVER_ROOT_URL=http://grafana.server.name" -e "GF_SECURITY_ADMIN_PASSWORD=secret" grafana/grafana
设置登录密码:secret
登录账号为:admin
配置data source:点击Add data source-->点击prometheus-->settings
max_source_resolution=5m&timeout=10
Grafana通过dashboard展示数据
5、下载dashboard(https://grafana.com/dashboards?dataSource=prometheus&search=docker)
下载完,得到一个json文件,导入Grafana(+àimportàupload.json file)