监控指标定义
TensorFusion 把指标和组件日志写入 GreptimeDB,共 9 张表,表名都以 tf_ 开头。本页列出每张表的标签和字段,写看板、告警规则、成本报表的 SQL 时可以直接查。
指标怎么采集
| 来源 | 表 | 采集间隔 |
|---|---|---|
| Controller | tf_system_metrics、tf_pool_metrics、tf_node_metrics、tf_gpu_metrics、tf_worker_resources、tf_gpu_allocation | 1 分钟 |
| Hypervisor(每个 GPU 节点一个) | tf_gpu_usage、tf_worker_usage | 默认 1 分钟,由 Hypervisor 启动参数 -metrics-interval 设置 |
| Vector(日志采集) | tf_system_log | 持续采集 |
Controller 和 Hypervisor 先把指标追加到本地文件,Vector sidecar 读取文件,再按 InfluxDB 行协议写入 GreptimeDB。除非你把 chart 指向集群外的 GreptimeDB,否则指标不出集群。
Helm values 的 dynamicConfig 下有 3 个配置项控制这条链路:
| 配置项 | 默认值 | 含义 |
|---|---|---|
metricsTTL | 30d | 所有 tf_ 表的数据保留时间。修改后无需重启即可生效。 |
metricsFormat | influx | 写入指标文件的行格式,可选 influx、json、otel。chart 自带的 Vector 配置只接收 influx。 |
metricsExtraPodLabels | {} | Pod 标签名到指标标签名的映射。列出的 Pod 标签会作为额外标签写入 tf_worker_resources 和 tf_gpu_allocation。 |
约定
- 标签(Tag)用来标识一条时间序列,带索引;字段(Field)是采集到的数值。
- 每张表都有一个时间索引列
greptime_timestamp,写入精度为毫秒。由早期版本启动时建表语句建出来的表用的是ts;用SELECT table_name, column_name FROM information_schema.columns WHERE semantic_type = 'TIMESTAMP';可以确认集群里是哪一个。 - 算力单位是 FP16 TFLOPS,显存单位是字节。名字里带
percent或percentage的字段取值范围是 0 到 100。 - “已分配(allocated)”指工作负载 requests 之和,“已限额(limited)”指工作负载 limits 之和。
- “虚拟容量”等于物理容量乘以 GPU 池的超卖比例。
集群和 GPU 池
tf_system_metrics
调度和扩缩容计数器,每个 GPU 池一行。计数从 Controller 启动开始累加,Controller 重启后归零,查询时请取一段时间内的差值。
| 标签 | 说明 |
|---|---|
pool | GPUPool 名称 |
| 字段 | 类型 | 说明 |
|---|---|---|
total_workers_cnt | int64 | GPU 池中正在运行的 worker 数量 |
total_nodes_cnt | int64 | GPU 池中的 GPU 节点数量 |
total_allocation_success_cnt | int64 | GPU 分配成功次数 |
total_allocation_fail_cnt | int64 | GPU 分配失败次数 |
total_scale_up_cnt | int64 | 预留给扩容事件。当前版本不累加,恒为 0。 |
total_scale_down_cnt | int64 | 预留给缩容事件。当前版本不累加,恒为 0。 |
total_topo_satisfied_cnt | int64 | 至少有一个节点满足 GPU 拓扑要求的调度次数 |
total_topo_unsatisfied_cnt | int64 | 没有节点满足 GPU 拓扑要求的调度次数 |
total_topo_fallback_cnt | int64 | 降级到更宽松拓扑的调度次数 |
total_topo_search_degraded_cnt | int64 | 拓扑搜索以降级模式运行的调度次数 |
调度器为该 GPU 池处理过至少一次分配后,才会写入 4 个 total_topo_* 字段。
tf_pool_metrics
每个 GPU 池的容量和分配汇总。
| 标签 | 说明 |
|---|---|
pool | GPUPool 名称 |
phase | GPUPool 所处阶段 |
| 字段 | 类型 | 说明 |
|---|---|---|
allocated_tflops | float64 | 工作负载请求的算力 |
allocated_tflops_percent | float64 | 请求算力占物理容量的百分比 |
allocated_tflops_percent_virtual | float64 | 请求算力占虚拟容量的百分比 |
allocated_vram_bytes | float64 | 工作负载请求的显存 |
allocated_vram_percent | float64 | 请求显存占物理容量的百分比 |
allocated_vram_percent_virtual | float64 | 请求显存占虚拟容量的百分比 |
limited_tflops | float64 | 工作负载算力 limits 之和 |
limited_tflops_percent_virtual | float64 | 算力 limits 占虚拟容量的百分比 |
limited_vram_bytes | float64 | 工作负载显存 limits 之和 |
limited_vram_percent_virtual | float64 | 显存 limits 占虚拟容量的百分比 |
gpu_count | int64 | GPU 池中的 GPU 数量 |
节点和 GPU
tf_node_metrics
每个 GPU 节点的分配情况和硬件成本。
| 标签 | 说明 |
|---|---|
node | GPUNode 名称 |
pool | GPUPool 名称 |
phase | GPUNode 所处阶段 |
| 字段 | 类型 | 说明 |
|---|---|---|
allocated_tflops | float64 | 节点上工作负载请求的算力 |
allocated_tflops_percent | float64 | 请求算力占节点物理容量的百分比 |
allocated_tflops_percent_virtual | float64 | 请求算力占节点虚拟容量的百分比 |
allocated_vram_bytes | float64 | 节点上工作负载请求的显存 |
allocated_vram_percent | float64 | 请求显存占节点物理容量的百分比 |
allocated_vram_percent_virtual | float64 | 请求显存占节点虚拟容量的百分比 |
gpu_count | int64 | 节点上的 GPU 数量 |
raw_cost | float64 | 上次采样以来节点 GPU 的硬件成本,单位美元,按每种 GPU 型号的小时单价计算 |
tf_gpu_metrics
调度器视角下每张 GPU 的容量和分配情况。
| 标签 | 说明 |
|---|---|
gpu | GPU 资源名称 |
node | GPUNode 名称 |
pool | GPUPool 名称 |
gpu_model | GPU 型号,例如 A10G |
phase | GPU 所处阶段 |
| 字段 | 类型 | 说明 |
|---|---|---|
capacity_tflops | float64 | GPU 的算力容量 |
available_tflops | float64 | 尚未被请求的算力 |
allocated_tflops | float64 | 工作负载请求的算力 |
allocated_tflops_percent | float64 | 请求算力占容量的百分比 |
capacity_vram_bytes | float64 | GPU 的显存容量 |
available_vram_bytes | float64 | 尚未被请求的显存 |
allocated_vram_bytes | float64 | 工作负载请求的显存 |
allocated_vram_percent | float64 | 请求显存占容量的百分比 |
tf_gpu_usage
每张物理 GPU 的硬件读数,由 Hypervisor 通过厂商库采集。
| 标签 | 说明 |
|---|---|
uuid | GPU UUID,小写 |
node | GPUNode 名称 |
pool | GPUPool 名称 |
| 字段 | 类型 | 说明 |
|---|---|---|
compute_percentage | float64 | GPU 利用率 |
memory_bytes | int64 | 已用显存 |
temperature | float64 | GPU 温度,单位 °C |
power_usage | float64 | 功耗,单位瓦 |
rx | float64 | PCIe 接收吞吐,单位字节每秒 |
tx | float64 | PCIe 发送吞吐,单位字节每秒 |
memory_percentage | float64 | 预留字段。当前 Hypervisor 上报 0,请用 memory_bytes 除以 tf_gpu_metrics 的 capacity_vram_bytes 计算。 |
compute_tflops | float64 | 预留字段。当前 Hypervisor 上报 0。 |
表里还有 graphics_clock_mhz、sm_clock_mhz、memory_clock_mhz、video_clock_mhz、nvlink_rx、nvlink_tx 这几列。只有厂商库把它们作为扩展指标上报时才有值;自带的 NVIDIA 库不上报,所以通常为空。
工作负载
tf_worker_resources
每个 worker Pod 的 requests、limits 和计费成本,由 Controller 记录。
| 标签 | 说明 |
|---|---|
worker | worker Pod 名称 |
workload | TensorFusionWorkload 名称 |
namespace | worker 所在命名空间 |
pool | GPUPool 名称 |
qos | QoS 等级:low、medium、high、critical,默认 medium |
| 字段 | 类型 | 说明 |
|---|---|---|
tflops_request | float64 | 每张 GPU 的算力 request |
tflops_limit | float64 | 每张 GPU 的算力 limit |
vram_bytes_request | float64 | 每张 GPU 的显存 request |
vram_bytes_limit | float64 | 每张 GPU 的显存 limit |
gpu_count | int64 | 分配给 worker 的 GPU 数量 |
raw_cost | float64 | 上次采样以来 worker 的费用,单位美元,按 GPU 池的 QoS 定价计算。GPU 池没有为该 QoS 等级定价时为 0。 |
ready | bool | worker Pod 是否就绪 |
raw_cost 是增量,不是累计值。要得到某段时间的费用,对这段时间内的值求和。
tf_worker_usage
每个 worker 在每张 GPU 上的实际用量,由 Hypervisor 测量。使用两张 GPU 的 worker 每次采样产生两行。
| 标签 | 说明 |
|---|---|
worker | worker 的 Pod UID |
pod_name | worker Pod 名称 |
workload | TensorFusionWorkload 名称,取不到时为 unknown |
namespace | worker 所在命名空间 |
pool | GPUPool 名称 |
node | GPUNode 名称 |
uuid | 这一行对应的 GPU UUID |
| 字段 | 类型 | 说明 |
|---|---|---|
compute_percentage | float64 | worker 各进程的 GPU 利用率之和 |
memory_bytes | int64 | worker 各进程占用的显存 |
memory_percentage | float64 | 已用显存占 worker 显存 limit 的百分比 |
compute_tflops | float64 | 预留字段。当前 Hypervisor 上报 0。 |
表结构里还有 compute_throttled_cnt、vram_freezed_cnt、vram_resumed_cnt 三列,当前 Hypervisor 不写入。
注意:worker 在 tf_worker_resources 里是 Pod 名称,在 tf_worker_usage 里是 Pod UID。关联两张表时,用 tf_worker_resources.worker 匹配 tf_worker_usage.pod_name。
tf_gpu_allocation
每个 Pod 占用了哪些 GPU,每个 Pod 一行。
| 标签 | 说明 |
|---|---|
pod | Pod 名称 |
namespace | Pod 所在命名空间 |
pod_uuid | Pod UID |
node | Pod 所在节点 |
gpu_name | 已分配 GPU 的名称,逗号分隔 |
gpu_model_index | 型号:序号 列表,逗号分隔,例如 A10G:0,A10G:1 |
| 字段 | 类型 | 说明 |
|---|---|---|
gpu_count | int64 | 分配给 Pod 的 GPU 数量 |
日志
tf_system_log
Controller、Hypervisor 和 worker 的容器日志,由 Vector 采集。
| 列 | 类型 | 说明 |
|---|---|---|
component | string | Pod 标签 tensor-fusion.ai/component 的值:operator、hypervisor 或 worker |
namespace | string | Pod 所在命名空间 |
pod | string | Pod 名称 |
container | string | 容器名称 |
message | string | 日志内容,带全文索引 |
stream | string | stdout 或 stderr |
timestamp | string | 日志写入时间 |
greptime_timestamp | timestamp | 时间索引,精度为毫秒 |
查询示例
最近 1 小时各工作负载请求的显存和实际用到的显存峰值:
SELECT r.workload,
max(r.vram_bytes_request) AS requested_bytes,
max(u.memory_bytes) AS peak_used_bytes
FROM tf_worker_resources r
JOIN tf_worker_usage u ON r.worker = u.pod_name
WHERE r.greptime_timestamp > now() - INTERVAL '1 hour'
AND u.greptime_timestamp > now() - INTERVAL '1 hour'
GROUP BY r.workload;最近 1 天各命名空间的费用:
SELECT namespace, sum(raw_cost) AS cost_usd
FROM tf_worker_resources
WHERE greptime_timestamp > now() - INTERVAL '1 day'
GROUP BY namespace;
TensorFusion 文档