You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Grafana配置告警规则时出现TypeError读取values属性错误求助

Grafana告警配置触发TypeError错误的排查与解决

问题详情

在Grafana告警模块设置查询语句和告警条件时,持续弹出以下错误:

An unexpected error happened
Details
TypeError: Cannot read properties of undefined (reading 'values')

at ni (http://localhost:3000/public/build/AlertingRuleForm.f65c22acec748d21665e.js:145:233)
at div
at de (http://localhost:3000/public/build/9512.8f35f1c2de682ecc2973.js:2:92536)
at li (http://localhost:3000/public/build/AlertingRuleForm.f65c22acec748d21665e.js:252:28)
at div
at de 

使用的InfluxDB查询语句:

from(bucket:"API_BE")
    |> range(start: -15m)
    |> filter(fn: (r) => r._measurement == "3 API competition")
    |> yield()

环境信息:

  • Grafana版本:9.3.2
  • InfluxDB版本:v2.6.0
  • 运行环境:Windows 10本地机器

排查与解决方法

1. 补全查询语句,明确数值字段

当前查询仅过滤了测量项(_measurement),未指定具体的数值字段(_field),Grafana告警需要明确的数值指标来判定条件。修改查询,添加字段过滤逻辑,示例如下(假设要监控的字段为response_time):

from(bucket:"API_BE")
    |> range(start: -15m)
    |> filter(fn: (r) => r._measurement == "3 API competition" and r._field == "response_time")
    |> yield()

如果需要聚合计算,可追加聚合函数(如取平均值):

from(bucket:"API_BE")
    |> range(start: -15m)
    |> filter(fn: (r) => r._measurement == "3 API competition" and r._field == "response_time")
    |> mean()
    |> yield()

2. 验证查询结果是否为空

先在InfluxDB的Data Explorer中执行该查询,确认是否有返回数据:

  • 检查bucket名称、_measurement名称是否拼写正确,注意大小写和特殊字符(比如空格)
  • 临时扩大时间范围(如改为-1h),确认目标时间区间内是否存在数据
  • 若查询结果为空,Grafana告警表单会因无法读取数据字段触发values未定义错误

3. 升级Grafana版本

Grafana 9.3.x版本存在部分告警表单的已知兼容bug,尤其是与InfluxDB v2.x的适配问题。建议升级到9.4.x或更高稳定版本,官方后续版本修复了不少前端表单的异常问题。

4. 检查数据源配置

确认Grafana中InfluxDB数据源的配置项:

  • 验证API Token是否拥有对应bucket的读写权限
  • 确认组织名称(Organization)填写正确
  • 通过数据源页面的「Test」按钮测试连通性,确保数据源连接正常

内容的提问来源于stack exchange,提问作者AutoMationKing

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.06 20:10:25