惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Recent Announcements
Recent Announcements
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
O
OpenAI News
D
Docker
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
N
Netflix TechBlog - Medium
人人都是产品经理
人人都是产品经理
Y
Y Combinator Blog
M
MIT News - Artificial intelligence
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
博客园 - 司徒正美
C
CXSECURITY Database RSS Feed - CXSecurity.com
阮一峰的网络日志
阮一峰的网络日志
K
Kaspersky official blog
Security Latest
Security Latest
T
Tailwind CSS Blog
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
V
Vulnerabilities – Threatpost
W
WeLiveSecurity
N
News and Events Feed by Topic
aimingoo的专栏
aimingoo的专栏
美团技术团队
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
Google DeepMind News
Google DeepMind News
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
C
Cyber Attacks, Cyber Crime and Cyber Security
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
B
Blog
T
The Blog of Author Tim Ferriss
Google DeepMind News
Google DeepMind News
Help Net Security
Help Net Security
爱范儿
爱范儿
宝玉的分享
宝玉的分享
腾讯CDC
H
Heimdal Security Blog
Webroot Blog
Webroot Blog
AI
AI
WordPress大学
WordPress大学
Recorded Future
Recorded Future
SecWiki News
SecWiki News
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
Security Archives - TechRepublic
Security Archives - TechRepublic
Google Online Security Blog
Google Online Security Blog
C
Check Point Blog
TaoSecurity Blog
TaoSecurity Blog
Cisco Talos Blog
Cisco Talos Blog
The Cloudflare Blog
www.infosecurity-magazine.com
www.infosecurity-magazine.com
博客园 - Franky
云风的 BLOG
云风的 BLOG

mafeifan 的编程技术分享

mafengwo-mp3-downloader | mafeifan 的编程技术分享 示例页面 | mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 查看 default namespace 下的 default service account名称 mafeifan 的编程技术分享 检查日志 | mafeifan 的编程技术分享 bridge fdb show dev flannel.1 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 数据收集原理分析 | mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 几种方法 | mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 check the export on the very top of this document so we can use $do mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 延伸 -- 关于前端路由 xdebug 3 和 2 的区别
mafeifan 的编程技术分享
2026-01-16 · via mafeifan 的编程技术分享

当前,容器的使用已经非常普及,将服务迁移到容器上正成为了越来越多公司的选择。而对于运维人员而言,熟悉容器的使用与监控,也已成为一项必不可少的专业技能。

关于容器的开源产品,目前知名的有Docker、Containerd、CoreOS rkt、LXC 等,在这其中Docker占据了绝对的统治地位,也是当前使用最广泛的容器产品。

本文将介绍通过Prometheus实现Docker容器监控的方案,关于Docker的技术本文不做讲解,不熟悉的朋友可先自行查阅相关资料。

一. CAdvisor工具 ​

CAdvisor为Google开源的一款用于监控和展示容器运行状态的可视化工具。CAdvisor可直接运行在主机上,它不仅可以搜集到机器上所有运行的容器信息,还提供查询界面和http接口,方便如Prometheus等监控系统进行数据的获取。 CAdvisor的安装很简单,可通过容器的方式进行部署。

  1. 下载镜像

$ docker pull google/cadvisor:latest

  1. 启动容器

bash

$ docker run \
  --volume=/:/rootfs:ro \
  --volume=/var/run:/var/run:rw \
  --volume=/sys:/sys:ro \
  --volume=/var/lib/docker/:/var/lib/docker:ro \
  --volume=/dev/disk/:/dev/disk:ro \
  --publish=8080:8080 \
  --detach=true \
  --name=cadvisor \
  --privileged=true \
  google/cadvisor:latest

注解:该命令在容器中挂载了几个目录,ro代表只读,CAdvisor将从其中收集数据。 rw代表可读写,此处指定/var/run目录,用于Docker套接字的挂载; --detach将以守护进程的方式运行; --name对生成的容器进行命名; 在Ret Hat,CentOS, Fedora 等发行版上需要传递如下参数--privileged=true。

  1. 查看容器状态,已正常启动
$ docker ps |grep cadvisor
13eb99bc02ce   google/cadvisor:latest   "/usr/bin/cadvisor -…"   19 minutes ago   Up 19 minutes   0.0.0.0:8080->8080/tcp   cadvisor
  1. 访问页面

浏览器打开http://:8080$ip ,可查看CAdvisor的web界面

访问http://:8080$ip/metrics,可看到相关的metrics指标信息

二. 容器指标 ​

以下是比较常用到的一些容器指标:

CPU指标

container_cpu_load_average_10s       #最近10秒容器的CPU平均负载情况
container_cpu_usage_seconds_total    #容器的CPU累积占用时间

内存指标

container_memory_max_usage_bytes     #容器的最大内存使用量(单位:字节)
container_memory_usage_bytes        #容器的当前内存使用量(单位:字节)
container_spec_memory_limit_bytes    #容器的可使用最大内存数量(单位:字节)

网络指标

container_network_receive_bytes_total   #容器网络累积接收字节数据总量(单位:字节)
container_network_transmit_bytes_total  #容器网络累积传输数据总量(单位:字节)

三. Prometheus集成 ​

CAdvisor是一个简单易用的工具,它除了有详细的监控指标,也提供了可供查看的WEB图表界面。但CAdvisor本身的数据保存时间只有2分钟,而且在多主机的情况下,要单独去登录每台机器查看docker数据也是一件麻烦的事情。

对此,更好的方法是与Prometheus集成,实现Docker容器数据的收集与保存。由于CAdvisor提供了支持Prometheus的metrics格式接口,所以Prometheus只需要按照获取Exporter指标的方式,创建相关的Job即可。 示例:

yaml

- job_name: 'docker'
    static_configs:
    - targets:
      -  '192.168.214.108:8080'
      labels:
        group: docker

任务正常启动后,我们可以在Prometheus查看到相关的指标

四. Grafana展示 ​

Grafana提供了不少Docker相关的Dashboard,可根据自己情况选择合适模板导入。 填写需要导入的Dashboard ID号(193),点击Load

导入完成后,可看到新的Dashboard已生效。