Skip to content

newlines break yaml syntax, prometheus fails to start #1

@pellywog

Description

@pellywog

description

When using some of the rules, prometheus-server fails to start with the following error message:

Aug 19 00:34:36 server prometheus-server[26365]: level=error ts=2020-08-18T22:34:36.695Z caller=main.go:764 err="error loading config from \"/etc/prometheus/prometheus.yml\": one or more errors occurred while applying the new configuration (--config.file=\"/etc/prometheus/prometheus.yml\")"

Config:

/etc/prometheus/prometheus.yml:
rule_files:
  - "rules.d/load-average.yml"

File used: https://raw.githubusercontent.com/patricktoelle/prometheus-rules/master/rules/generic/load-average.rules.yml

Expected behavior

Prometheus should start without errors.

Proposed fix

Here is a working example of the first rule in the load-average.rules.yml:

groups:
- name: load-average.rules
  rules:
  - alert: NodeLoadAverage
    expr: ((node_load5 / count without (cpu, mode) (node_cpu{mode="system"})) > 1) or (node_load5 / count without (cpu, mode) (node_cpu_seconds_total{mode="system"})) > 1
    for: 6h
    labels:
      severity: warning
      priority: P3
      paging: false
    annotations:
      summary: High Load on {{ $labels.instance }} detected
      description: "{{ $labels.instance }} Average load is above threshold (current value is: {{ $value }})"

There should be no newlines. I also tried:

foo: |
  bla
  foo
  bar

which also does not work. Only fix I found was to remove the newlines completely.

PS: The disk check for example does work, even with newlines.. I'm not sure what exactly is causing the issue - I just included all your rules at once and then noticed prometheus fails to start.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions