寫在前面
cAdvisor
:google開源的一個docker container監(jiān)控工具,自帶web ui乏苦,并支持導出到prometheus六荒、influxdb等存儲;
prometheus
+ grafana
安裝看這里蝗砾。
安裝配置
cAdvisor
-
配置用戶名密碼
為cAdvisor web ui生成認證文件auth.htpasswd
,用戶http basic認證:yum install -y httpd-tools htpasswd -b -c auth.htpasswd user1 password1
-
docker-compose
配置
將auth.htpasswd
與docker-compose.yml
放到同一目錄下:version: '3.3' services: cadvisor: image: google/cadvisor:v0.33.0 ports: - "8030:8080" volumes: - /:/rootfs:ro - /var/run:/var/run:rw - /sys:/sys:ro #- /var/lib/docker/:/var/lib/docker:ro - /apps/data/docker/:/var/lib/docker:ro - /dev/disk/:/dev/disk:ro - /cgroup:/cgroup:ro - ./auth.htpasswd:/etc/auth.htpasswd command: - '--http_auth_file=/etc/auth.htpasswd' privileged: true devices: - /dev/kmsg
啟動并驗證
docker-compose up -d
啟動先较,瀏覽器訪問cAdvisor web uihttp://{host}:8030
,輸入用戶名密碼登錄悼粮,可以看到如下界面:
- 每臺宿主機分別啟動
cAdvisor
Prometheus
prometheus.yml
添加job闲勺,指向cAdvisor
http地址:
scrape_configs:
- job_name: 'cadvisor_docker_exporter'
static_configs:
- targets:
- 192.168.0.182:8030
- 192.168.1.10:8030
- 192.168.3.220:8030
Grafana
- 導入dashboard模板
docker-container.json - 查看效果