【问题标题】:Trying to configure prometheus with alert manager but getting error with rules file尝试使用警报管理器配置普罗米修斯,但规则文件出错
【发布时间】:2020-05-28 07:04:42
【问题描述】:

在我的 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/

Prometheus 版本是 2.18.1

希望有人帮忙

谢谢 KK

【问题讨论】:

    标签: prometheus prometheus-alertmanager


    【解决方案1】:

    您正在使用 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
    

    【讨论】:

    • 是的,我正在使用 rules.yml,使用 rule_file 子句。非常感谢您,我愿意接受您的回答,因为这是正确的,非常感谢您的回复
    猜你喜欢
    • 2021-07-24
    • 1970-01-01
    • 2021-12-24
    • 2022-11-02
    • 1970-01-01
    • 2019-02-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多