尝试使用警报管理器配置普罗米修斯但规则文件出错 [英] Trying to configure prometheus with alert manager but getting error with rules file
问题描述
在我的 prometheus.yml 中,规则文件名为 rules.yml,它有这个
In my prometheus.yml,the rules file is called rules.yml and it has this
---
groups:
- name: example
rules:
- alert: ServiceDown
expr: up == 0
for: 2m
labels:
severity: critical
annotations:
summary: cannot connect to {{ $labels.job }}
当我运行 sudo ./promtool check config rules.yml 我得到错误
when i run sudo ./promtool check config rules.yml i get the error
Checking rules.yml
FAILED: parsing YAML file rules.yml: yaml: unmarshal errors:
line 2: field groups not found in type config.plain
我不知道出了什么问题,因为我正在关注这个https://prometheus.io/docs/prometheus/latest/configuration/alerting_rules/
I am not sure what is wrong as i am following this https://prometheus.io/docs/prometheus/latest/configuration/alerting_rules/
Prometheus 版本为 2.18.1
Prometheus version is 2.18.1
希望有人帮忙
谢谢KK
推荐答案
您正在使用 Prometheus 配置文件中的rule_file"子句加载 rules.yml,对吗?
You are loading the rules.yml using the "rule_file" clause in the Prometheus configuration file, right?
rule_files:
- rules.yml
我注意到我们不能直接对规则文件执行promtool check config",但是如果你对 Prometheus 配置文件执行它,它会正确地检查规则文件:
I notice that we can't execute the "promtool check config" directly to the rule file but if you execute it to the Prometheus configuration file it'll check the rule file correctly:
$ promtool check config prometheus.yaml
Checking prometheus.yaml
SUCCESS: 1 rule files found
Checking rules.yaml
SUCCESS: 18 rules found
这篇关于尝试使用警报管理器配置普罗米修斯但规则文件出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!