Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prometheus 2.2.0-rc.1 alerts does not support advanced yaml anchor syntax #3889

Closed
freznicek opened this Issue Feb 26, 2018 · 2 comments

Comments

Projects
None yet
2 participants
@freznicek
Copy link

freznicek commented Feb 26, 2018

What did you do?

I failed to use advanced yaml anchor syntax in prometheus alert definition.

Why I want that? I want to reduce alert definition duplications.

This prometheus alert rule yaml fails to parse due to strict field existence rules:

.comm-labels: &comm-labels
  team: xxxxxxxxxxxx@yyyyyyyyyyyy.cz
  severity: critical
  #pager: pagerduty

groups:
- name: dns_resolve_error
  rules:

  # Aserver application
  # -------------------------------------------------------------------------
  - alert: AServerDNSResolveError
    expr: increase(errors_total{app="aserver",type="DNSResolveError"}[2m]) > 10
    for: 4m
    labels:
      <<: *comm-labels
    annotations:
      title: Pod {{$labels.namespace}}/{{$labels.instance}}, locality {{$labels.locality}} sees {{ $value }} DNSResolveError[s] for host {{$labels.remote_app}}
      description: Aserver detected more than 10 DNSResolveError issues per 2 minutes (lasts for at least 4 minutes)
      playbook: howto/k8s-dns-failures.md

  # BServer application
  # -------------------------------------------------------------------------
  - alert: BServerDNSResolveError
    expr: increase(errors_total{app=~"bserver.*",type=~"DNSResolveError|YError"}[2m]) > 10
    for: 4m
    labels:
      <<: *comm-labels
    annotations:
      title: Pod {{$labels.namespace}}/{{$labels.instance}}, locality {{$labels.locality}} sees {{ $value }} DNSResolveError[s] for host {{$labels.remote_app}}
      description: BServer detected more than 10 DNSResolveError issues per 2 minutes (lasts for at least 4 minutes)
      playbook: howto/k8s-dns-failures.md

Promtool alert checker says:

$ promtool check rules /tmp/prometheus_alert_1.yaml
Checking /tmp/prometheus_alert_1.yaml
  FAILED:
unknown fields in config_file: .comm-labels

What did you expect to see?

I'd like to see prometheus supporting <<: * syntax.
Moreover Prometheus should define which fields are ignored, for instance the way as gitlab-ci.yml does (ignores everything strating with dot).

What did you see instead? Under which circumstances?

Above alert not valid:

$ promtool check rules /tmp/prometheus_alert_1.yaml
Checking /tmp/prometheus_alert_1.yaml
  FAILED:
unknown fields in config_file: .comm-labels

Environment

  • System information:
    multiple specs:
    Linux 4.6.0-0.bpo.1-amd64 x86_64
    Linux 4.11.12-100.fc24.x86_64 x86_64

  • Prometheus version:

* prometheus docker image: prom/prometheus:v2.2.0-rc.1

$ promtool --version
promtool, version 2.2.0-rc.0 (branch: HEAD, revision: 1fe05d40e4b2f4f7479048b1cc3c42865eb73bab)
  build user:       root@f7abb25edc70
  build date:       20180213-11:40:47
  go version:       go1.9.2

  • Prometheus configuration file:
    Sorry cannot disclose this at this point.

  • Logs:

$ promtool check rules /tmp/prometheus_alert_1.yaml
Checking /tmp/prometheus_alert_1.yaml
  FAILED:
unknown fields in config_file: .comm-labels
@brian-brazil

This comment has been minimized.

Copy link
Member

brian-brazil commented Mar 3, 2018

If you want to template files then using the templating feature of your configuration management system.

This is expected behaviour, unknown fields cause an error to warn about typos and in general I would recommend avoiding the YAML anchor features.

@lock

This comment has been minimized.

Copy link

lock bot commented Mar 22, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked and limited conversation to collaborators Mar 22, 2019

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
You can’t perform that action at this time.