观测容器

概述

参考:

容器的 Observability 如何实现?

Docker 为什么不内置 cAdvisor?docker stats 命令为什么不设计个接口直接吐出来 OpenMetrics 格式的数据?

cAdvisor

参考:

Container Advisor(容器顾问,简称 cAdvisor) 为容器用户提供了对其运行中容器的资源使用情况和性能特征的深入理解。它是一个持续运行的守护进程,负责收集、汇总、处理并导出有关运行容器的信息。具体而言,它会记录每个容器的资源隔离参数、历史资源使用情况、完整历史资源使用直方图以及网络统计信息。这些数据会按容器和整机维度分别导出。

cAdvisor 被集成在 Kubelet

暴露的指标

  • cadvisor_version_info 具有常数“1”值的度量,由内核版本、操作系统版本、docker 版本、cadvisor 版本和 cadvisor 修订版标记。
  • container_cpu_cfs_periods_total 已用强制周期间隔数。
  • container_cpu_cfs_throttled_periods_total 节流周期间隔数。
  • container_cpu_cfs_throttled_seconds_total 容器被限制的总持续时间。
  • container_cpu_load_average_10s 过去 10 秒内容器 cpu 负载平均值的值。
  • container_cpu_system_seconds_total 以秒为单位消耗的累积系统 CPU 时间。
  • container_cpu_usage_seconds_total 以秒为单位消耗的累积 CPU 时间。
  • container_cpu_user_seconds_total 以秒为单位消耗的累积用户 cpu 时间。
  • container_file_descriptors 容器的打开文件描述符数。
  • container_fs_inodes_free 可用索引节点数
  • container_fs_inodes_total inode 数
  • container_fs_io_current 当前正在进行的 I/O 数
  • container_fs_io_time_seconds_total 花费在 I/O 上的累计秒数
  • container_fs_io_time_weighted_seconds_total 累积加权 I/O 时间(以秒为单位)
  • container_fs_limit_bytes 此文件系统上的容器可以消耗的字节数。
  • container_fs_read_seconds_total 阅读花费的累计秒数
  • container_fs_reads_bytes_total 读取的累积字节数
  • container_fs_reads_merged_total 合并读取的累积计数
  • container_fs_reads_total 已完成读取的累计计数
  • container_fs_sector_reads_total 已完成扇区读取的累积计数
  • container_fs_sector_writes_total 已完成扇区写入的累积计数
  • container_fs_usage_bytes 此文件系统上的容器消耗的字节数。
  • container_fs_write_seconds_total 写入花费的累计秒数
  • container_fs_writes_bytes_total 写入字节的累积计数
  • container_fs_writes_merged_total 合并写入的累积计数
  • container_fs_writes_total 已完成写入的累积计数
  • container_last_seen 上次导出器看到容器的时间
  • container_memory_cache 页缓存内存的字节数。
  • container_memory_failcnt 内存使用次数达到限制
  • container_memory_failures_total 内存分配失败的累积计数。
  • container_memory_mapped_file 内存映射文件的大小(以字节为单位)。
  • container_memory_max_usage_bytes 以字节为单位记录的最大内存使用量
  • container_memory_rss RSS 的大小(以字节为单位)。
  • container_memory_swap 容器交换使用量(以字节为单位)。
  • container_memory_usage_bytes 当前内存使用量(以字节为单位),包括所有内存,无论何时访问
  • container_memory_working_set_bytes 当前工作集(以字节为单位)。
  • container_network_receive_bytes_total 接收字节的累计计数
  • container_network_receive_errors_total 接收时遇到的错误累积计数
  • container_network_receive_packets_dropped_total 接收时丢弃的数据包的累积计数
  • container_network_receive_packets_total 接收的数据包的累积计数
  • container_network_transmit_bytes_total 传输的累积字节数
  • container_network_transmit_errors_total 传输时遇到的错误累积计数
  • container_network_transmit_packets_dropped_total 传输时丢弃的数据包的累积计数
  • container_network_transmit_packets_total 传输的数据包的累积计数
  • container_processes 在容器内运行的进程数。
  • container_scrape_error 1 如果在获取容器指标时出错,则为 0 否则
  • container_sockets 容器打开的套接字数。
  • container_spec_cpu_period 容器的 CPU 周期。
  • container_spec_cpu_quota 容器的 CPU 配额。
  • container_spec_cpu_shares 容器的 CPU 份额。
  • container_spec_memory_limit_bytes 容器的内存限制。
  • container_spec_memory_reservation_limit_bytes 容器的内存预留限制。
  • container_spec_memory_swap_limit_bytes 容器的内存交换限制。
  • container_start_time_seconds 自 Unix 纪元以来容器的启动时间(以秒为单位)。
  • container_tasks_state 处于给定状态的任务数
  • container_threads 容器内运行的线程数
  • container_threads_max 容器内允许的最大线程数,如果值为零则无穷大
  • container_ulimits_soft 容器根进程的软 ulimit 值。如果 -1 则无限制,优先级和好除外

Grafana 面板