TensorFusion Docs

配置告警

为 TensorFusion 集群和工作负载配置告警

TensorFusion 内置告警评估器,定期查询 GreptimeDB 中的指标,并把告警发送到 Prometheus AlertManager。默认 Helm 配置会启用告警评估和内置 AlertManager;生产环境可以改为接入已有 AlertManager。

告警规则依赖 GreptimeDB 中的 TensorFusion 指标。若指标采集未就绪,AlertManager 正常运行也不会收到有效告警。

告警链路

告警链路由三部分组成:

  1. Controller 启动参数启用告警评估:-enable-alert
  2. dynamicConfig.alertRules 定义查询规则、阈值和告警文案
  3. AlertManager 负责去重、分组、静默和通知

默认 Helm values 中已包含 worker 限流、显存切换、调度失败、GPU 高温、GPU 满载、资源池容量不足、空闲 GPU 等内置规则。

使用内置 AlertManager

如果没有现成的 AlertManager,可以使用 chart 内置的 AlertManager:

# values-alert.yaml
alert:
  enabled: true
  replicaCount: 1
  alertManagerConfig:
    global: {}
    receivers:
      - name: default-receiver
    route:
      receiver: default-receiver
      group_wait: 10s
      group_interval: 5m
      repeat_interval: 3h

应用配置:

helm upgrade --install --create-namespace --namespace tensor-fusion-sys \
  --repo https://download.tensor-fusion.ai \
  -f values-alert.yaml \
  tensor-fusion-sys tensor-fusion

检查 AlertManager:

kubectl -n tensor-fusion-sys get pod -l tensor-fusion.ai/component=alert-manager
kubectl -n tensor-fusion-sys get svc alert-manager

接入已有 AlertManager

如果集群已有统一 AlertManager,请关闭内置 AlertManager,并把 Controller 的 -alert-manager-addr 指向现有服务:

# values-alert.yaml
controller:
  command:
    - /manager
    - -metrics-bind-address
    - :9000
    - -leader-elect
    - -enable-auto-scale
    - -enable-alert
    - -enable-auto-expander
    - -alert-manager-addr
    - http://alertmanager.monitoring.svc.cluster.local:9093
alert:
  enabled: false

-alert-manager-addr 需要包含协议和端口,例如 http://alertmanager.monitoring.svc.cluster.local:9093。通知路由、接收人、静默策略可以继续在原 AlertManager 中维护。

自定义告警规则

自定义规则写在 dynamicConfig.alertRules。规则中的 SQL 查询 GreptimeDB 指标表,{{ .Conditions }} 会由告警评估器替换为时间窗口条件。

示例:GPU 温度连续过高时告警。

# values-alert.yaml
dynamicConfig:
  metricsTTL: 30d
  metricsFormat: influx
  alertRules:
    - name: GPUTemperatureHigh
      query: |
        SELECT
          node,
          pool,
          uuid,
          avg(temperature) AS avg_temperature
        FROM tf_gpu_usage
        WHERE temperature > {{ .Threshold }} AND {{ .Conditions }}
        GROUP BY node, pool, uuid
      threshold: 90
      evaluationInterval: 30s
      consecutiveCount: 3
      severity: P1
      summary: "GPU 温度过高:{{ .node }} {{ .uuid }}"
      description: "GPU {{ .uuid }} 在 {{ .node }} 上连续高于 {{ .Threshold }}°C,当前平均 {{ .avg_temperature }}°C"
      alertTargetInstance: "{{ .uuid }}"
      runbookURL: "https://tos.run/docs/tensor-engine/troubleshooting/handbook"

常用字段:

字段作用
name告警名称,也是 AlertManager 中的 alertname
queryGreptimeDB SQL,返回的列可用于模板渲染
threshold阈值,可在 SQL 中通过 {{ .Threshold }} 引用
evaluationInterval评估周期,例如 30s1m
consecutiveCount连续命中多少次后触发告警
severity告警级别,例如 P0P1P2
summary / description告警标题和详情,支持引用查询结果列
alertTargetInstance告警实例标识,用于去重和恢复
runbookURL排障手册链接

可查询的指标表包括 tf_worker_usagetf_gpu_usagetf_system_metricstf_node_metrics 等。字段说明参考监控指标定义

验证告警配置

更新 values 后执行:

helm upgrade --install --create-namespace --namespace tensor-fusion-sys \
  --repo https://download.tensor-fusion.ai \
  -f values-alert.yaml \
  tensor-fusion-sys tensor-fusion

确认配置已写入 ConfigMap:

kubectl -n tensor-fusion-sys get configmap tensor-fusion-sys-config -o yaml
kubectl -n tensor-fusion-sys logs deployment/tensor-fusion-sys-controller-manager -c manager --tail=100

如果使用内置 AlertManager,可以临时端口转发查看告警状态:

kubectl -n tensor-fusion-sys port-forward svc/alert-manager 9093:9093

然后访问 http://localhost:9093

常见问题

没有收到告警

先确认 Controller 启动参数包含 -enable-alert,再检查 -alert-manager-addr 是否可访问。使用内置 AlertManager 时,确认 alert.enabled=true 且 AlertManager Pod Ready。

规则一直不触发

用 GreptimeDB 控制台单独执行规则 SQL,确认查询能返回数据。时间条件、表名、字段名和阈值是最常见问题。

告警重复太多

调整 alertTargetInstancegroup_intervalrepeat_intervalconsecutiveCount。同一资源的告警实例应保持稳定,避免 AlertManager 无法去重。

目录