测试规则 AlertManager 失败:yaml:解组错误:第 1 行:在类型 main.unitTestFile 中找不到字段组

Faj*_*nto 5 alert prometheus prometheus-alertmanager

请帮助我在下面测试警报管理器时收到错误消息

 promtool check rules /etc/prometheus/alert.rules.yml
 Checking /etc/prometheus/alert.rules.yml
 SUCCESS: 3 rules found

 promtool test rules /etc/prometheus/alert.rules.yml
 Unit Testing:  /etc/prometheus/alert.rules.yml
 FAILED:
 yaml: unmarshal errors:
 line 1: field groups not found in type main.unitTestFile
Run Code Online (Sandbox Code Playgroud)

我的alert.rules配置如下:

      cat /etc/prometheus/alert.rules.yml
      groups:
      - alert: MemoryFree10%
        expr: node_exporter:node_memory_free:memory_used_percents >= 90
        for: 5m
        labels:
          severity: critical
        annotations:
          summary: "Instance {{ $labels.instance }} hight memory usage"
          description: "{{ $labels.instance }} has more than 90% of its memory used."
      - alert: DiskSpace10%Free
        expr: node_exporter:node_filesystem_free:fs_used_percents >= 90
        labels:
          severity: moderate
        annotations:
          summary: "Instance {{ $labels.instance }} is low on disk space"
          description: "{{ $labels.instance }} has only {{ $value }}% free."
      - alert: ExporterDown
        expr: up == 0
        for: 5m
        labels:
          severity: warning
        annotations:
          summary: "Exporter down (instance {{ $labels.instance }})"
          description: "Prometheus exporter down\n  VALUE = {{ $value }}\n  LABELS: {{ $labels }}"
Run Code Online (Sandbox Code Playgroud)

我们的文件警报规则是否有遗漏或不正确?

请帮忙?

谢谢

Amj*_*yed -1

您的配置缺少规则。

    groups:
    - name: alert.rules
      rules:
      - alert: HighRequestLatency
      .....
Run Code Online (Sandbox Code Playgroud)

https://prometheus.io/docs/prometheus/latest/configuration/alerting_rules/