Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign upDisplay rules as defined in configuration #5370
Comments
This comment has been minimized.
This comment has been minimized.
|
This is a limitation of the YAML parser we use, once it's better we can do better. |
This comment has been minimized.
This comment has been minimized.
|
The YAML parser seems capable to handle comments and multiline strings quite all right: package main
import (
"fmt"
yaml "gopkg.in/yaml.v2"
)
type T struct {
A string `yaml:"a"`
}
var (
conf = `a: |
(
# Pod is down and rename label "kubernetes_pod_name" to "pod"
label_replace(up{job="kubernetes-pods"}, "pod", "$1", "kubernetes_pod_name", "(.*)")
*
# Add node label to up{}
on (pod) group_left(node) avg(kube_pod_info) by (pod, node)
) == 0
AND # Node is ready
on (node) kube_node_status_condition{condition="Ready",status="true"} == 1`
)
func main() {
t := T{}
yaml.UnmarshalStrict([]byte(conf), &t)
fmt.Printf("%s\n-----------\n", conf)
fmt.Printf("%s\n", t.A)
}
|
This comment has been minimized.
This comment has been minimized.
|
Ah, you're looking at the rules page. Those are what the PromQL printer produces. On a page like that it's best to have the actual AST, rather than what may be a confusingly written expression.
Actually that's all multi-line strings. PromQL supports # comments. |
This comment has been minimized.
This comment has been minimized.
|
I'm talking at the alerts page really but it's the same problem.
I beg to differ, when you write a rule with indentation, comments and such to make it understandable and easily editable, having it reduced to it's simplest form is what is confusing. |
This comment has been minimized.
This comment has been minimized.
|
That's presuming you get the indentation etc. right. When debugging knowing how it's actually parsed is important. |
This comment has been minimized.
This comment has been minimized.
That's not a valid concern, a simple
Maybe a few prometheus developpers are actually debugging prometheus query parser, users are concerned to understand the sens of query that have been written by their colleagues. |
This comment has been minimized.
This comment has been minimized.
I don't see how that helps. If someone's has misleading indentation, it'll still be misleading.
I meant debugging queries, not Prometheus. |
This comment has been minimized.
This comment has been minimized.
And so much for those who get it right ? Your leveling down philosophy is disturbing. I think you've been embedded in this project for a long time now and you can't comprehend anymore the complexity of PromQL and how it is struggling for occasional users. I've been writing the alert rules for the system of my company and improving them along the way made them more and more complex. I recently showed the more complex ones to my on call colleagues (the ones those very rules will be awaking at night) and they looked back at me with disgust. Indentation & comments are essential for my colleagues to understand what's underlying the alerts. |
This comment has been minimized.
This comment has been minimized.
This is from experience, it's not the ones that get it right that I have to spend time on. The rules are on disk if you wish to view them. |
This comment has been minimized.
This comment has been minimized.
|
Which isn't to say the current printer couldn't be improved with some indentation and newlines. |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
That's non-standard indentation, anything on this page should be in a canonical form. |
This comment has been minimized.
This comment has been minimized.
|
No, it should be as written in configuration. |
This comment has been minimized.
This comment has been minimized.
|
I agree with @brian-brazil We have lots of complex PromQL and it helps to see how Prometheus "compiles" that. I do not want to see my "garbage" in the console. I have the files for it. |
This comment has been minimized.
This comment has been minimized.
|
That's the problem here, you only think of yourselves and don't think about how other people might need to understand your rules in the middle of the night. |
This comment has been minimized.
This comment has been minimized.
|
That is not true. I am making heavy usage of annotations for on call people. I even implemented the option to see the annotations of the alerts on that page to help on call. |
This comment has been minimized.
This comment has been minimized.
|
(And on call also has access to the rule files + ansible repos.. with the original queries) |
This comment has been minimized.
This comment has been minimized.
|
I think the general idea is to have some kind of Note that |
beorn7
referenced this issue
Mar 16, 2019
Closed
promtool rules migration produces unreadable rule files #3115
This comment has been minimized.
This comment has been minimized.
|
Aaand this idea is actually ancient – which I knew, but I forgot we have an issue for it: #21. It is, in fact, the second oldest still open issue… |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
All right. |

sylr commentedMar 15, 2019
Proposal
Use case. Why is this important?
Prometheus rules can be quite complex thus the use of comments, new lines, uppercased keywords ... etc can help make it easier to understand.
E.G:
Unfortunately the Prometheus UI does not display the rules as they were written but like if a "sanitizer" have been applied, i.e.:
The latter is really quite indigest so it would be nice if you could keep the formatting as it.