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

`promtool update rules` discards comments #3475

Closed
vthriller opened this Issue Nov 14, 2017 · 4 comments

Comments

Projects
None yet
2 participants
@vthriller
Copy link
Contributor

vthriller commented Nov 14, 2017

What did you do?

promtool update rules rulefile

What did you expect to see?

Given the following rulefile:

# Lorem ipsum

ALERT Foo
  # whatever
  IF bar > 0
  or rate(baz [1m]) > 0 # because reasons
  #or quux > 0 # FIXME
  LABELS { severity = "crit" }

I expected to see the output silimlar to this:

# Lorem ipsum
groups:
- # whatever
  name: test
  rules:
  - alert: Foo
    expr: |
      bar > 0
      or rate(baz[1m]) > 0 # because reasons
      #or quux > 0 # FIXME
    labels:
      severity: crit

(or #or quux to be on the same level as labels: or whatever)

What did you see instead? Under which circumstances?

groups:
- name: test
  rules:
  - alert: Foo
    expr: bar > 0 or rate(baz[1m]) > 0
    labels:
      severity: crit

Environment

  • System information: (irrelevant)

  • Prometheus version:

promtool, version 2.0.0 (branch: HEAD, revision: 0a74f98628a0463dddc90528220c94de5032d1a0)
  build user:       root@615b82cb36b6
  build date:       20171108-07:11:59
  go version:       go1.9.2
  • Alertmanager version: (irrelevant)

  • Prometheus configuration file: (irrelevant)

  • Alertmanager configuration file: (irrelevant)

  • Logs: (none)

@brian-brazil

This comment has been minimized.

Copy link
Member

brian-brazil commented Nov 14, 2017

This is a limitation of the YAML libraries available in Go, I'm afraid there's not much we can do about this.

@vthriller

This comment has been minimized.

Copy link
Contributor Author

vthriller commented Nov 14, 2017

I'm afraid there's not much we can do about this

There's little to no reason (value escaping?) to use libraries for content generation, and since the output is pretty flat, it might as well be generated by hand. But even then you'd need to hack parser to allow it to output comments in some form.

(That being said, I'm not sure if this issue affects a lot of people and is therefore worth the effort, but here it is.)

@brian-brazil

This comment has been minimized.

Copy link
Member

brian-brazil commented Nov 22, 2017

Unless you can find a Golang yaml library that supports comments, there's nothing we can do here.

@lock

This comment has been minimized.

Copy link

lock bot commented Mar 23, 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 23, 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.