KKR
KKR

Reputation: 67

Trying to configure prometheus with alert manager but getting error with rules file

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 }}

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

I am not sure what is wrong as i am following this https://prometheus.io/docs/prometheus/latest/configuration/alerting_rules/

Prometheus version is 2.18.1

Hoping for some assistance from someone

Thanks KK

Upvotes: 2

Views: 4482

Answers (1)

You are loading the rules.yml using the "rule_file" clause in the Prometheus configuration file, right?

rule_files:
  - rules.yml

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

Upvotes: 4

Related Questions