C:CAdvisor ----- docker容器性能、状态等信息收集
I:InfluxDB ----- 将C收集的信息进行存储
G:Granfana ----- 将存储的信息进行可视化展示
下面将会使用上面这三个工具进行搭建docker的监控平台
docker-compose.yml
编写docker-compose一键搭建监控平台
运行这个compose文件之前建议先把这三个镜像先给pull下来,否则,是个非常漫长的过程
version: '3.1'
volumes:
grafana_data: {}
services:
influxdb:
image: tutum/influxdb:0.9
restart: always
environment:
- PRE_CREATE_DB=cadvisor
ports:
- "8083:8083"
- "8086:8086"
volumes:
- ./data/influxdb:/data
cadvisor:
image: google/cadvisor
links:
- influxdb:influxsrv
command: -storage_driver=influxdb -storage_driver_db=cadvisor -storage_driver_host=influxsrv:8066
restart: always
ports:
- "8080:8080"
volumes:
- /:/rootfs:ro
- /var/run:/var/run:rw
- /sys:/sys:ro
- /var/lib/docker/:/var/lib/docker:ro
grafana:
user: "104"
image: grafana/grafana
restart: always
links:
- influxdb:influxsrv
ports:
- "3000:3000"
volumes:
- grafana_data:/var/lib/grafana
environment:
- HTTP_USER=admin
- HTTP_PASS=admin
- INFLUXDB_HOST=influxsrv
- INFLUXDB_PORT=8086
- INFLUXDB_NAME=cadvisor
- INFLUXDB_USER=root
- INFLUXDB_PASS=root
验证编写配置是否正确:docker-compose config -q
执行:docker-compose up 或 docker-compose up -d
验证
-
docker ps查看是否启动成功
-
访问CAdvisor收集服务:http://ip:8080/
-
访问InfluxDB存储服务:http://ip:8083/
-
访问Granfana展示服务:http://ip:3000/ [默认账号/密码:admin/admin]
配置Grafana
配置数据源
Configuration ----> Add data source ----> InfluxDB
添加面板
Create —> dashboard —> Add a new panel
创建完之后进行保存