架构师_程序员_码农网

 找回密码
 注册[Register]

QQ登录

只需一步,快速开始

查看: 2426|回复: 1

【实战】使用 cAdvisor 收集 Docker 容器指标

[复制链接]
发表于 2022-1-25 10:32:09 | 显示全部楼层 |阅读模式
需求:查看 docker 容器的运行状况,收集容器的各种指标,搜索“container_exporter”,找到了:https://github.com/docker-archive/infra-container_exporter 发现已经弃用,推荐使用“cAdvisor”。

cAdvisor (Container Advisor)

GitHub 地址:https://github.com/google/cadvisor

文档:https://github.com/google/cadvisor/blob/master/docs/running.md

cAdvisor (Container Advisor) 让容器用户了解他们正在运行的容器的资源使用和性能特征。它是一个正在运行的守护进程,用于收集、聚合、处理和导出有关正在运行的容器的信息。具体来说,它为每个容器保存资源隔离参数、历史资源使用情况、完整历史资源使用情况的直方图和网络统计信息。此数据由容器和机器范围导出。

Docker 直接查看容器资源消耗命令如下:
QQ截图20220125092838.jpg

Docker 直接查看服务的磁盘使用信息命令如下:

我使用的环境如下:

  • Docker version 20.10.10
  • CentOS 7 64位

[root@itsvse-doc ~]# docker version
Client: Docker Engine - Community
Version:           20.10.10
API version:       1.41
Go version:        go1.16.9
Git commit:        b485636
Built:             Mon Oct 25 07:44:50 2021
OS/Arch:           linux/amd64
Context:           default
Experimental:      true

Server: Docker Engine - Community
Engine:
  Version:          20.10.10
  API version:      1.41 (minimum version 1.12)
  Go version:       go1.16.9
  Git commit:       e2f740d
  Built:            Mon Oct 25 07:43:13 2021
  OS/Arch:          linux/amd64
  Experimental:     false
containerd:
  Version:          1.4.11
  GitCommit:        5b46e404f6b9f661a205e28d59c982d3634148f8
runc:
  Version:          1.0.2
  GitCommit:        v1.0.2-0-g52b36a2
docker-init:
  Version:          0.19.0
  GitCommit:        de40ad0

运行 cAdvisor

以 CentOS 7 为例,命令如下:


尝试使用浏览器访问:http://192.168.1.213:8085/,如下图:

QQ截图20220125101646.jpg QQ截图20220125101711.jpg

使用 Prometheus 监控 cAdvisor

回顾:

Grafana+Prometheus+Node Exporter 获取 Linux 服务器指标
https://www.itsvse.com/thread-9971-1-1.html

Grafana+Prometheus+Windows Exporter 监控服务性能指标
https://www.itsvse.com/thread-9671-1-1.html

尝试访问:http://192.168.1.213:8085/metrics,如下图:

QQ截图20220125101727.jpg

文档:https://github.com/google/cadvisor/blob/master/docs/storage/prometheus.md

Grafana 仪表板地址:https://github.com/vegasbrianc/grafana_dashboard


prometheus.yml 配置如下:

重启 prometheus 服务,来获取 docker 运行指标。

使用 grafana 导入仪表盘,运行几分钟后,如下图:

QQ截图20220125103038.jpg




上一篇:【实战】CentOS 7 使用 rpm 方式安装 MySQL 数据库
下一篇:Spring Boot MessageSource 国际化语言的坑
码农网,只发表在实践过程中,遇到的技术难题,不误导他人。
 楼主| 发表于 2022-1-25 13:25:54 | 显示全部楼层
码农网,只发表在实践过程中,遇到的技术难题,不误导他人。
您需要登录后才可以回帖 登录 | 注册[Register]

本版积分规则

免责声明:
码农网所发布的一切软件、编程资料或者文章仅限用于学习和研究目的;不得将上述内容用于商业或者非法用途,否则,一切后果请用户自负。本站信息来自网络,版权争议与本站无关。您必须在下载后的24个小时之内,从您的电脑中彻底删除上述内容。如果您喜欢该程序,请支持正版软件,购买注册,得到更好的正版服务。如有侵权请邮件与我们联系处理。

Mail To:help@itsvse.com

QQ|手机版|小黑屋|架构师 ( 鲁ICP备14021824号-2 )|网站地图

GMT+8, 2024-4-19 13:21

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表