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

使用promtool检查规则文件报错:field groups not found in type config.plain

解决promtool check config报错:field groups not found in type config.plain

你遇到的问题是因为用错了promtool命令。promtool check config是用来校验Prometheus主配置文件(比如prometheus.yml)的,而你的文件是告警规则文件,应该用专门的规则校验命令。

错误场景

执行命令:

promtool check config rules.yaml

得到错误:

Checking rules.yaml
FAILED: parsing YAML file c.yaml: yaml: unmarshal errors:
line 1: field groups not found in type config.plain

你的告警规则文件内容正确:

groups:
- name: example
  rules:
  - alert: HighRequestLatency
    expr: job:request_latency_seconds:mean5m{job="myjob"} > 0.5
    for: 10m
    labels:
      severity: page
    annotations:
      summary: High request latency

解决方案

改用promtool check rules命令校验告警规则文件:

promtool check rules rules.yaml

原因说明

promtool的两个check子命令职责不同:

  • check config:验证Prometheus主配置文件,该文件的顶级字段是global、scrape_configs等,不包含groups
  • check rules:专门验证告警规则或记录规则文件,这类文件的顶级字段就是groups,与你的文件结构匹配

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.18 02:55:20