gpt4 book ai didi

prometheus - 尝试使用警报管理器配置普罗米修斯但规则文件出错

转载 作者:行者123 更新时间:2023-12-04 09:47:58 25 4
gpt4 key购买 nike

在我的 prometheus.yml 中,规则文件被称为 rules.yml,它有这个

---
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 我收到错误
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/

普罗米修斯版本是 2.18.1

希望得到某人的帮助

谢谢
KK

最佳答案

您正在使用 Prometheus 配置文件中的“rule_file”子句加载 rules.yml,对吗?

rule_files:
- rules.yml

我注意到我们不能直接对规则文件执行“promtool check config”,但是如果你对 Prometheus 配置文件执行它,它会正确地检查规则文件:
$ promtool check config prometheus.yaml

Checking prometheus.yaml
SUCCESS: 1 rule files found

Checking rules.yaml
SUCCESS: 18 rules found

关于prometheus - 尝试使用警报管理器配置普罗米修斯但规则文件出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62058871/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com