Docker Container 可观测性最佳实践

Docker Container 介绍

Docker Container( Docker 容器)是一种轻量级、可移植的、自给自足的软件运行环境,它在 Docker 引擎的宿主机上运行。容器在许多方面类似于虚拟机,但它们更轻量,因为它们不需要模拟整个操作系统。相反,容器共享宿主机的操作系统内核,并在用户空间中运行。

Docker 容器可观测对于确保容器化应用程序的性能、稳定性和可用性至关重要,本文主要以纯 Docker 环境下(非K8S ),构建 Container 的可观测性。

观测云

使用观测云可以轻松采集到容器的 cpu 、内存、网络、IO 等核心指标,并自动采集容器的标准输出日志,使用观测云可以有效地监控和管理容器化应用程序,一键实现容器可观测。

部署 DataKit

登录观测云,点击集成按钮,选择 DataKit,会自动生成安装 DataKit 命令。

DataKit 安装完成后,默认开启了 container 采集器,container 采集器主要采集 K8S 和 docker 容器的指标、日志等信息。执行命令 datakit monitor 可以数据查看采集情况,在 Inputs Info 中 logging/xxx 表明正在采集当前 xxx 容器的日志,container-mertic 表明正在采集容器的指标。

关键指标

  • docker_containers
Metric Description Type Unit
block_read_byte Total number of bytes read from the container file system (only supported docker). int B
block_write_byte Total number of bytes wrote to the container file system (only supported docker). int B
cpu_numbers The number of the CPU core. int count
cpu_usage The percentage usage of CPU on system host. float percent
cpu_usage_base100 The normalized cpu usage, with a maximum of 100%. float percent
mem_capacity The total memory in the host machine. int B
mem_limit The limit memory in the container. int B
mem_usage The usage of the memory. int B
mem_used_percent The percentage usage of the memory is calculated based on the capacity of host machine. float percent
mem_used_percent_base_limit The percentage usage of the memory is calculated based on the limit. float percent
network_bytes_rcvd Total number of bytes received from the network (only count the usage of the main process in the container, excluding loopback). int B
network_bytes_sent Total number of bytes send to the network (only count the usage of the main process in the container, excluding loopback). int B

视图

登录观测云控制台,点击「场景」 -「新建仪表板」,输入 "docker" , 选择 "Docker 监控视图",点击 "确定" 即可添加内置视图。

  • 概览
  • CPU & 内存
  • IO & Network
  • 日志

监控器(告警)

容器重启告警

容器启动时间小于5分钟,触发容器重启告警。

CPU 利用率告警

容器 cpu 使用率,基于宿主机总 cpu 百分比利用率进行判断触发告警。

内存利用率告警

容器内存使用率,基于容器内存限制(没有设置容器内存限制按照主机最大内存计算)进行判断触发告警。

监控效果

  • 重启告警
  • 监控自动恢复

总结

在观测云的助力下,一键部署 Agent,自动采集 Docker 相关的日志、指标等数据, 在平台一键开启监控 Dashboard 和监控器,实时观测容器运行情况,使容器可观测性变的方便、快捷、高效。

相关推荐
cyber_两只龙宝6 小时前
haproxy--实现能7层负载均衡、基于cookie会话保持、状态页监控的高性能web服务器集群
linux·运维·负载均衡·监控·haproxy·会话保持·高性能集群
程序员羽毛2 天前
🚀 股票量化多策略盯盘哨兵 V3.0.0 涨停板监控+回测+回放+摸鱼全搞定
股票量化·监控·提醒·股票策略
少云清2 天前
【软件测试】9_性能测试实战 _性能测试监控
性能测试·监控
A-刘晨阳2 天前
Prometheus + Grafana + Alertmanager 实现邮件监控告警及配置告警信息
运维·云计算·grafana·prometheus·监控·邮件
盛世宏博北京4 天前
《合规 GB/T 50356:小型档案馆(100㎡)恒温恒湿自动化方案》
监控·档案温湿度
OpsEye4 天前
监控 100 问(五):监控数据的分析与可视化
运维·网络·信息可视化·it·监控·监控系统
玄德公笔记4 天前
Prometheus监控k8s的metric详解(第二版)-01-scrape 指标抓取
kubernetes·k8s·prometheus·监控·metric·scrape·k8s监控
无线图像传输研究探索9 天前
硬盘录像机(NVR)+ 车载设备:车载图传监控解决方案,重塑移动监控新生态
车载系统·监控·无线图传·车载·车载监控·车载图传
A-刘晨阳11 天前
【Linux】Prometheus + Grafana的使用
linux·运维·grafana·prometheus·监控
盛世宏博北京11 天前
高效节能型档案库房恒温恒湿自动化控制系统方案
大数据·档案·监控·温湿度