使用docker部署prometheus
1.1 启动Prometheus相关容器
(1)启动prometheus server
docker run -dp 9089:9090 --restart always --name prometheus_server prom/prometheus:v2.37.6
(2)启动node-exporter
docker run -dp 9100:9100 --restart always --name node-exporter prom/node-exporter:v1.5.0
(3)启动cadvisor
docker run --volume=/:/rootfs:ro --volume=/var/run:/var/run:rw --volume=/sys:/sys:ro --volume=/var/lib/docker/:/var/lib/docker:ro --publish=8081:8080 --detach=true --name=cadvisor google/cadvisor:v0.33.0
(4)修改prometheus server配置文件
docker exec -it prometheus_server sh
vi /etc/prometheus/prometheus.yml
...
scrape_configs:
- targets: ["localhost:9089"]
...
- job_name: "docker-node_exporter"
static_configs:
- targets: ["192.168.0.118:9100"]
- job_name: "docker-cadvisor"
static_configs:
- targets: ["192.168.0.118:8081"]
(5)重启prometheus server容器使得配置生效
# docker 部署 重新启动
docker restart prometheus_server
1.2 使用granfa查看容器监控并添加仪表盘
(1)启动grafana容器
docker run --name=grafana -dp 3000:3000 --restart always grafana/grafana-enterprise
http://192.168.0.118:3000
访问Prometheus
http://192.168.0.118:9089
访问node-exporter
http://192.168.0.118:9100
访问cadvisor
http://192.168.0.118:8081/containers/
访问granfa
http://192.168.0.118:3000