写在前面
cAdvisor
:google开源的一个docker container监控工具,自带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 - 查看效果
网友评论