监控docker2
cadvisor是谷歌开发的容器监控工具,在host中运行cadvisor容器
[root@localhost ~]# docker run -v /:/rootfs:ro -v /var/run/:/var/run:ro -v /sys:/sys:ro -v /var/lib/docker:/var/lib/docker -P -d --name cadvisor3 google/cadvisor
5e7ad001b3916a9bfd7c2c2ebf235a4cb69efe71426692303124bc7969fe7478
通过192.168.172.129:32768
点击docker containers 连接
显示容器列表
点击某个容器,进入该容器的监控页面
cadvisor的主要功能,总结起来有两点:
1:展示host和容器两个层次的监控数据
2:展示历史数据变化
环境说明
我们将通过prometheus 监控两台docker host
[root@localhost ~]# 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|rootfs/var/lib/docker/containers|rootfs/var/lib/docker/overlay2|rootfs/run/docker/netns|rootfs/var/lib/docker/devicemapper|rootfs/var/lib/docker/aufs)($$|/)" Unable to find image 'prom/node-exporter:latest' locally latest: Pulling from prom/node-exporter 86fa074c6765: Pull complete ed1cd1c6cd7a: Pull complete ff1bb132ce7b: Pull complete Digest: sha256:cf66a6bbd573fd819ea09c72e21b528e9252d58d01ae13564a29749de1e48e0f Status: Downloaded newer image for prom/node-exporter:latest WARNING: Published ports are discarded when using host network mode 16b8ec370c424b6566692a5fde1fc784c2fcd2e05acf2bab750fb98478e5676c [root@localhost ~]#
访问
运行prometheus server
docker run -d -P -v /root/prometheus.yml:/etc/prometheus/prometheus.yml --name prometheus --net=host prom/prometheus
cat prometheus.yml
static_configs: - targets: ['localhost:9090','localhost:32768','localhost:9100','192.168.172.128:32768','192.168.172.129:9100']
运行grafana
[root@localhost ~]# docker run -d -i -P -e "GF_SERVER_ROOT_URL=http://grafana.server.name" > -e "GF_SECURITY_ADMIN_PASSWORD=secret" > --net=host grafana/grafana Unable to find image 'grafana/grafana:latest' locally latest: Pulling from grafana/grafana cbdbe7a5bc2a: Pull complete 22c9cde4b77a: Pull complete 02653346ebaa: Pull complete 40bd12673834: Pull complete 947c86dbd478: Pull complete 36508129e563: Pull complete Digest: sha256:a24849c210ebea3ec754594302faa49d5a21460cdc14ab30dd38d8938a865f09 Status: Downloaded newer image for grafana/grafana:latest bdb83f0eda52cf91b74e41faa4f62686a14890287060b91ea09ec8f63271e916 [root@localhost ~]#
访问