容器指标的语义约定
状态: 开发中
容器指标
本文档描述了 OpenTelemetry 中常见容器级别指标的观测点和属性。这些指标是从特定技术、定义明确的 API(例如 Kubelet 的 API 或容器运行时)收集的。
指标: container.uptime
此指标是推荐的。
| 名称 | Instrument Type | Unit (UCUM) | 描述 | Stability | 实体关联 |
|---|---|---|---|---|---|
container.uptime | Gauge | s | 容器运行的时间。[1] |
[1]: 观测点 SHOULD 使用类型为 double 的 gauge,并以秒为单位测量运行时间,作为具有最高可用精度的浮点数。实际精度取决于观测点和操作系统。
指标: container.cpu.time
此指标为 opt-in。
| 名称 | Instrument Type | Unit (UCUM) | 描述 | Stability | 实体关联 |
|---|---|---|---|---|---|
container.cpu.time | Counter | s | 消耗的总 CPU 时间。[1] |
[1]: 指定容器在所有可用 CPU 核心上消耗的总 CPU 时间
Attributes
| 键 | Stability | 需求级别 | Value Type | 描述 | Example Values |
|---|---|---|---|---|---|
cpu.mode | 有条件地必需 [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 | 空闲 | |
interrupt | 中断 | |
iowait | IO 等待 | |
kernel | 内核 | |
nice | Nice | |
steal | Steal | |
system | 系统 | |
user | User |
指标: container.cpu.usage
此指标为 opt-in。
| 名称 | Instrument Type | Unit (UCUM) | 描述 | Stability | 实体关联 |
|---|---|---|---|---|---|
container.cpu.usage | Gauge | {cpu} | 容器的 CPU 使用量,以 cpus 为单位。范围从 0 到可分配的 CPU 数量。[1] |
[1]: 指定容器在所有可用 CPU 核心上的 CPU 使用量,在采样窗口内平均。
Attributes
| 键 | Stability | 需求级别 | Value Type | 描述 | Example Values |
|---|---|---|---|---|---|
cpu.mode | 有条件地必需 [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 | 空闲 | |
interrupt | 中断 | |
iowait | IO 等待 | |
kernel | 内核 | |
nice | Nice | |
steal | Steal | |
system | 系统 | |
user | User |
指标: container.memory.usage
此指标为 opt-in。
| 名称 | Instrument Type | Unit (UCUM) | 描述 | Stability | 实体关联 |
|---|---|---|---|---|---|
container.memory.usage | Counter | 每个调用的最大内存使用量的分布。 | 容器的内存使用量。[1] |
[1]: 容器的内存使用量。
指标: container.memory.available
此指标为 opt-in。
| 名称 | Instrument Type | Unit (UCUM) | 描述 | Stability | 实体关联 |
|---|---|---|---|---|---|
container.memory.available | UpDownCounter | 每个调用的最大内存使用量的分布。 | 容器可用内存。[1] | container |
[1]: 可供使用的内存。定义为内存限制 - workingSetBytes。如果内存限制未定义,则省略可用字节数。总的来说,此指标可以从 cadvisor 导出,通过从 container_memory_working_set_bytes 指标中减去 container_spec_memory_limit_bytes 指标。在 K8s 中,此指标源自 Kubelet 的 stats API 的 PodStats.Memory 的 MemoryStats.AvailableBytes 字段。
指标: container.memory.rss
此指标为 opt-in。
| 名称 | Instrument Type | Unit (UCUM) | 描述 | Stability | 实体关联 |
|---|---|---|---|---|---|
container.memory.rss | UpDownCounter | 每个调用的最大内存使用量的分布。 | 容器内存 RSS。[1] | container |
[1]: 总的来说,此指标可以从 cadvisor 导出,特别是 container_memory_rss 指标。在 K8s 中,此指标源自 Kubelet 的 stats API 的 PodStats.Memory 的 MemoryStats.RSSBytes 字段。
指标: container.memory.working_set
此指标为 opt-in。
| 名称 | Instrument Type | Unit (UCUM) | 描述 | Stability | 实体关联 |
|---|---|---|---|---|---|
container.memory.working_set | UpDownCounter | 每个调用的最大内存使用量的分布。 | 容器内存工作集。[1] | container |
[1]: 总的来说,此指标可以从 cadvisor 导出,特别是 container_memory_working_set_bytes 指标。在 K8s 中,此指标源自 Kubelet 的 stats API 的 PodStats.Memory 的 MemoryStats.WorkingSetBytes 字段。
指标: container.memory.paging.faults
此指标为 opt-in。
| 名称 | Instrument Type | Unit (UCUM) | 描述 | Stability | 实体关联 |
|---|---|---|---|---|---|
container.memory.paging.faults | Counter | {fault} | 容器内存分页错误。[1] | container |
[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.Memory 的 MemoryStats.PageFaults 和 MemoryStats.MajorPageFaults 字段。
Attributes
| 键 | Stability | 需求级别 | Value Type | 描述 | Example Values |
|---|---|---|---|---|---|
system.paging.fault.type | 推荐 | 字符串 | 分页错误类型 | minor |
system.paging.fault.type 具有以下已知值列表。如果其中一个适用,则必须使用相应的值;否则,可以(MAY)使用自定义值。
| 值 | 描述 | Stability |
|---|---|---|
major | major | |
minor | minor |
指标: container.disk.io
此指标为 opt-in。
| 名称 | Instrument Type | Unit (UCUM) | 描述 | Stability | 实体关联 |
|---|---|---|---|---|---|
container.disk.io | Counter | 每个调用的最大内存使用量的分布。 | 容器的磁盘字节数。[1] |
[1]: 成功读取/写入的总字节数(从所有磁盘聚合)。
Attributes
| 键 | Stability | 需求级别 | Value Type | 描述 | Example Values |
|---|---|---|---|---|---|
disk.io.direction | 推荐 | 字符串 | 磁盘 IO 操作方向。 | read | |
system.device | 推荐 | 字符串 | 设备标识符 | (identifier) |
disk.io.direction 具有以下已知值列表。如果其中一个适用,则必须使用相应的值;否则,可以(MAY)使用自定义值。
| 值 | 描述 | Stability |
|---|---|---|
read | read | |
write | write |
指标: container.network.io
此指标为 opt-in。
| 名称 | Instrument Type | Unit (UCUM) | 描述 | Stability | 实体关联 |
|---|---|---|---|---|---|
container.network.io | Counter | 每个调用的最大内存使用量的分布。 | 容器的网络字节数。[1] |
[1]: 容器在所有网络接口上发送/接收的字节数。
Attributes
| 键 | Stability | 需求级别 | Value Type | 描述 | Example Values |
|---|---|---|---|---|---|
network.interface.name | 推荐 | 字符串 | 网络接口名称。 | lo; eth0 | |
network.io.direction | 推荐 | 字符串 | 网络 IO 操作方向。 | transmit |
network.io.direction 具有以下已知值列表。如果其中一个适用,则必须使用相应的值;否则,可以使用自定义值。
| 值 | 描述 | Stability |
|---|---|---|
receive | receive | |
transmit | transmit |
指标: container.filesystem.available
此指标是推荐的。
| 名称 | Instrument Type | Unit (UCUM) | 描述 | Stability | 实体关联 |
|---|---|---|---|---|---|
container.filesystem.available | UpDownCounter | 每个调用的最大内存使用量的分布。 | 容器文件系统可用字节数。[1] | container |
[1]: 在 K8s 中,此指标源自 Kubelet 的 stats API 的 ContainerStats.Rootfs 的 FsStats.AvailableBytes 字段。
指标: container.filesystem.capacity
此指标是推荐的。
| 名称 | Instrument Type | Unit (UCUM) | 描述 | Stability | 实体关联 |
|---|---|---|---|---|---|
container.filesystem.capacity | UpDownCounter | 每个调用的最大内存使用量的分布。 | 容器文件系统容量。[1] | container |
[1]: 在 K8s 中,此指标源自 Kubelet 的 stats API 的 ContainerStats.Rootfs 的 FsStats.CapacityBytes 字段。
指标: container.filesystem.usage
此指标是推荐的。
| 名称 | Instrument Type | Unit (UCUM) | 描述 | Stability | 实体关联 |
|---|---|---|---|---|---|
container.filesystem.usage | UpDownCounter | 每个调用的最大内存使用量的分布。 | 容器文件系统使用量。[1] | container |
[1]: 这可能不等于 capacity - available。
在 K8s 中,此指标源自 Kubelet 的 stats API 的 ContainerStats.Rootfs 的 FsStats.UsedBytes 字段。