prometheus - 尝试使用警报管理器配置普罗米修斯,但规则文件出错
问题描述
在我的 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
推荐阅读
- php - 如何为选择选项编写触发器?
- javascript - 如何使用 javasript 按日期对表格进行排序?
- java - 表达式的类型必须是数组类型,但它解析为 Instances
- node.js - PassportJS 未对用户进行身份验证
- asynchronous - N 进程障碍问题:在关键代码发出信号之后等待更好吗?
- swift - Xcode 中的 Swift 内存位置 - 字符串摘要
- django - 从 Django 中的表单数据读取 CSV 文件时出现“ValueError: I/O operation on closed file”
- java - 如何在无向图中获取从源到目的地的路径计数(基于非零)?
- swift - 为什么不工作 == 在两个相似的日期之间
- javascript - 有没有办法在带有反应的消息中添加文本