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

Rule formatting tool. #21

Open
juliusv opened this Issue Jan 4, 2013 · 13 comments

Comments

Projects
None yet
7 participants
@juliusv
Copy link
Member

juliusv commented Jan 4, 2013

Like "gofmt" for Go, we ought to have a "promfmt" for Prometheus since we have a syntax tree. The idea being that the system produces uniform style that minimizes deviation and learning curve.

matttproud added a commit that referenced this issue Apr 9, 2014

Merge pull request #21 from prometheus/feature/accept-header-discrimi…
…nation

Support Protocol Buffer Message Decoding
@grobie

This comment has been minimized.

Copy link
Member

grobie commented Jun 23, 2015

👍 * 💯

@fabxc

This comment has been minimized.

Copy link
Member

fabxc commented Jun 24, 2015

Yep, that'd be great. Preserving comments is the biggest (and basically only) problem. And agreement on how to split expressions over multiple lines.

@brian-brazil

This comment has been minimized.

Copy link
Member

brian-brazil commented Jul 16, 2016

Aren't we in the middle of adding this to promtool?

@mattbostock

This comment has been minimized.

Copy link
Contributor

mattbostock commented Oct 3, 2016

Related: #1779

simonpasquier pushed a commit to simonpasquier/prometheus that referenced this issue Oct 12, 2017

Merge pull request prometheus#21 from aeriff/protocol-relative-css
Use a protocol-relative URL to load Google Fonts

bobmshannon pushed a commit to bobmshannon/prometheus that referenced this issue Nov 19, 2018

pgier pushed a commit to pgier/prometheus that referenced this issue Jan 23, 2019

Merge pull request prometheus#21 from simonpasquier/fix-ocp-builds-fo…
…r-promu

Install promu package for OCP multistage builds
@beorn7

This comment has been minimized.

Copy link
Member

beorn7 commented Mar 16, 2019

Some observations:

  • With the 2.x rule format (YAML embedding PromQL), we want this to act on YAML files, too.
  • It should preserve both comments in YAML and in PromQL.
  • Indentation is crucial (not just line breaks).
  • It has to be seen if certain line breaks in the input should be preserved in the output (cf. how gofmt does it).
  • Wherever a rule is rendered, the same formatting should apply, in particular on the Alerts and Rules tabs of the Prometheus web UI. This implies that the AST needs to keep comments (and possibly certain line breaks, see previous point).
@brian-brazil

This comment has been minimized.

Copy link
Member

brian-brazil commented Mar 17, 2019

It should preserve both comments in YAML

Our current YAML library doesn't do this, but is hoping to "soon".

@geekodour

This comment has been minimized.

Copy link
Contributor

geekodour commented Mar 20, 2019

I'd like to include this in my gsoc proposal. @brian-brazil, can you link to the YAML library you're referring to?

@brian-brazil

This comment has been minimized.

Copy link
Member

brian-brazil commented Mar 20, 2019

https://github.com/go-yaml/yaml, but I'd scope this to just the PromQL as this stands.

@juliusv

This comment has been minimized.

Copy link
Member Author

juliusv commented Mar 20, 2019

@brian-brazil But since the PromQL from rules is always embedded in YAML files, it at least has to preserve YAML comments, right? Otherwise the tool wouldn't be very useful as nobody wants to lose their comments the benefit of formatting.

@brian-brazil

This comment has been minimized.

Copy link
Member

brian-brazil commented Mar 21, 2019

That'd be nice, but we can get benefits without that. I'd rather also not depend on something with an unclear timeline for a gsoc project.

@beorn7

This comment has been minimized.

Copy link
Member

beorn7 commented Mar 21, 2019

Let's start with the PromQL part. The YAML part should be almost trivial once the library preserves comments and things like the |2 indentation hint for multiline strings.

@juliusv

This comment has been minimized.

Copy link
Member Author

juliusv commented Mar 21, 2019

Ok!

@brian-brazil

This comment has been minimized.

Copy link
Member

brian-brazil commented Apr 5, 2019

v3 of the YAML library is out, which should allow for all of this.

dmitsh pushed a commit to dmitsh/prometheus that referenced this issue Apr 17, 2019

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