容器指标的语义约定

状态: 开发中

容器指标

本文档描述了 OpenTelemetry 中常见容器级别指标的观测点和属性。这些指标是从特定技术、定义明确的 API(例如 Kubelet 的 API 或容器运行时)收集的。

指标: container.uptime

此指标是推荐的。

名称Instrument TypeUnit (UCUM)描述Stability实体关联
container.uptimeGauges容器运行的时间。[1]Development

[1]: 观测点 SHOULD 使用类型为 double 的 gauge,并以秒为单位测量运行时间,作为具有最高可用精度的浮点数。实际精度取决于观测点和操作系统。

指标: container.cpu.time

此指标为 opt-in

名称Instrument TypeUnit (UCUM)描述Stability实体关联
container.cpu.timeCounters消耗的总 CPU 时间。[1]Development

[1]: 指定容器在所有可用 CPU 核心上消耗的总 CPU 时间

Attributes

Stability需求级别Value Type描述Example Values
cpu.modeDevelopment有条件地必需 [1]字符串此数据点的 CPU 模式。容器的 CPU 指标 SHOULD 要么通过没有 mode 标签的数据点来表征,要么仅通过带有 mode 标签的数据点来表征。[2]user; system

[1] cpu.mode: 如果模式可用,则必需,即来自 Docker Stats API 的指标。

[2] cpu.mode: SHOULD 使用以下状态:user, system, kernel


cpu.mode 具有以下已知值列表。如果其中一个适用,则必须使用相应的值;否则,可以(MAY)使用自定义值。

描述Stability
idle空闲Development
interrupt中断Development
iowaitIO 等待Development
kernel内核Development
niceNiceDevelopment
stealStealDevelopment
system系统Development
userUserDevelopment

指标: container.cpu.usage

此指标为 opt-in

名称Instrument TypeUnit (UCUM)描述Stability实体关联
container.cpu.usageGauge{cpu}容器的 CPU 使用量,以 cpus 为单位。范围从 0 到可分配的 CPU 数量。[1]Development

[1]: 指定容器在所有可用 CPU 核心上的 CPU 使用量,在采样窗口内平均。

Attributes

Stability需求级别Value Type描述Example Values
cpu.modeDevelopment有条件地必需 [1]字符串此数据点的 CPU 模式。容器的 CPU 指标 SHOULD 要么通过没有 mode 标签的数据点来表征,要么仅通过带有 mode 标签的数据点来表征。[2]user; system

[1] cpu.mode: 如果模式可用,则必需,即来自 Docker Stats API 的指标。

[2] cpu.mode: SHOULD 使用以下状态:user, system, kernel


cpu.mode 具有以下已知值列表。如果其中一个适用,则必须使用相应的值;否则,可以(MAY)使用自定义值。

描述Stability
idle空闲Development
interrupt中断Development
iowaitIO 等待Development
kernel内核Development
niceNiceDevelopment
stealStealDevelopment
system系统Development
userUserDevelopment

指标: container.memory.usage

此指标为 opt-in

名称Instrument TypeUnit (UCUM)描述Stability实体关联
container.memory.usageCounter每个调用的最大内存使用量的分布。容器的内存使用量。[1]Development

[1]: 容器的内存使用量。

指标: container.memory.available

此指标为 opt-in

名称Instrument TypeUnit (UCUM)描述Stability实体关联
container.memory.availableUpDownCounter每个调用的最大内存使用量的分布。容器可用内存。[1]Developmentcontainer

[1]: 可供使用的内存。定义为内存限制 - workingSetBytes。如果内存限制未定义,则省略可用字节数。总的来说,此指标可以从 cadvisor 导出,通过从 container_memory_working_set_bytes 指标中减去 container_spec_memory_limit_bytes 指标。在 K8s 中,此指标源自 Kubelet 的 stats API 的 PodStats.MemoryMemoryStats.AvailableBytes 字段。

指标: container.memory.rss

此指标为 opt-in

名称Instrument TypeUnit (UCUM)描述Stability实体关联
container.memory.rssUpDownCounter每个调用的最大内存使用量的分布。容器内存 RSS。[1]Developmentcontainer

[1]: 总的来说,此指标可以从 cadvisor 导出,特别是 container_memory_rss 指标。在 K8s 中,此指标源自 Kubelet 的 stats API 的 PodStats.MemoryMemoryStats.RSSBytes 字段。

指标: container.memory.working_set

此指标为 opt-in

名称Instrument TypeUnit (UCUM)描述Stability实体关联
container.memory.working_setUpDownCounter每个调用的最大内存使用量的分布。容器内存工作集。[1]Developmentcontainer

[1]: 总的来说,此指标可以从 cadvisor 导出,特别是 container_memory_working_set_bytes 指标。在 K8s 中,此指标源自 Kubelet 的 stats API 的 PodStats.MemoryMemoryStats.WorkingSetBytes 字段。

指标: container.memory.paging.faults

此指标为 opt-in

名称Instrument TypeUnit (UCUM)描述Stability实体关联
container.memory.paging.faultsCounter{fault}容器内存分页错误。[1]Developmentcontainer

[1]: 总的来说,此指标可以从 cadvisor 导出,特别是 container_memory_failures_total{failure_type=pgfault, scope=container}container_memory_failures_total{failure_type=pgmajfault, scope=container} 指标。在 K8s 中,此指标源自 Kubelet 的 stats API 的 PodStats.MemoryMemoryStats.PageFaultsMemoryStats.MajorPageFaults 字段。

Attributes

Stability需求级别Value Type描述Example Values
system.paging.fault.typeDevelopment推荐字符串分页错误类型minor

system.paging.fault.type 具有以下已知值列表。如果其中一个适用,则必须使用相应的值;否则,可以(MAY)使用自定义值。

描述Stability
majormajorDevelopment
minorminorDevelopment

指标: container.disk.io

此指标为 opt-in

名称Instrument TypeUnit (UCUM)描述Stability实体关联
container.disk.ioCounter每个调用的最大内存使用量的分布。容器的磁盘字节数。[1]Development

[1]: 成功读取/写入的总字节数(从所有磁盘聚合)。

Attributes

Stability需求级别Value Type描述Example Values
disk.io.directionDevelopment推荐字符串磁盘 IO 操作方向。read
system.deviceDevelopment推荐字符串设备标识符(identifier)

disk.io.direction 具有以下已知值列表。如果其中一个适用,则必须使用相应的值;否则,可以(MAY)使用自定义值。

描述Stability
readreadDevelopment
writewriteDevelopment

指标: container.network.io

此指标为 opt-in

名称Instrument TypeUnit (UCUM)描述Stability实体关联
container.network.ioCounter每个调用的最大内存使用量的分布。容器的网络字节数。[1]Development

[1]: 容器在所有网络接口上发送/接收的字节数。

Attributes

Stability需求级别Value Type描述Example Values
network.interface.nameDevelopment推荐字符串网络接口名称。lo; eth0
network.io.directionDevelopment推荐字符串网络 IO 操作方向。transmit

network.io.direction 具有以下已知值列表。如果其中一个适用,则必须使用相应的值;否则,可以使用自定义值。

描述Stability
receivereceiveDevelopment
transmittransmitDevelopment

指标: container.filesystem.available

此指标是推荐的。

名称Instrument TypeUnit (UCUM)描述Stability实体关联
container.filesystem.availableUpDownCounter每个调用的最大内存使用量的分布。容器文件系统可用字节数。[1]Developmentcontainer

[1]: 在 K8s 中,此指标源自 Kubelet 的 stats API 的 ContainerStats.RootfsFsStats.AvailableBytes 字段。

指标: container.filesystem.capacity

此指标是推荐的。

名称Instrument TypeUnit (UCUM)描述Stability实体关联
container.filesystem.capacityUpDownCounter每个调用的最大内存使用量的分布。容器文件系统容量。[1]Developmentcontainer

[1]: 在 K8s 中,此指标源自 Kubelet 的 stats API 的 ContainerStats.RootfsFsStats.CapacityBytes 字段。

指标: container.filesystem.usage

此指标是推荐的。

名称Instrument TypeUnit (UCUM)描述Stability实体关联
container.filesystem.usageUpDownCounter每个调用的最大内存使用量的分布。容器文件系统使用量。[1]Developmentcontainer

[1]: 这可能不等于 capacity - available。

在 K8s 中,此指标源自 Kubelet 的 stats API 的 ContainerStats.RootfsFsStats.UsedBytes 字段。