Hi everyone,
I'm automating a way to modify Grafana Dashboards to our liking. For
example to use a public Grafana dashboard and append certain query labels
to every query in a dashboard.
For this, I figured to use the Prometheus Parser, which works well to some
extend for my use-case. However certain 'expressions' (or queries) don't
parse that well (or I'm doing it wrong).
As a quick draft I have the following code:
------
parsedExpr, _ := parser.ParseExpr(expr)
childExprs := parser.Children(parsedExpr)
parsedMainMetric, _ := parser.ParseMetric(expr)
fmt.Println(parsedMainMetric)
for _, childExpr := range childExprs {
parsedChildExpr, _ := parser.ParseMetric(childExpr.String())
fmt.Println(parsedChildExpr)
}
------
Which works for:
> input: "rate(node_disk_io_time_seconds_total{bar=\"foo\"}[2m])",
As this gives me the following output:
> {__name__="rate"}
> {__name__="node_disk_io_time_seconds_total", bar="foo"}
However, lets say I change the input to:
> input: "rate(node_disk_io_time_seconds_total{bar=\"foo\"}[2m]) > 0",
Then it does not exactly go how I expected it to be:
> {__name__="rate"}
> {__name__="rate"}
> {}
(obviously this is mainly due to how I wrote my draft code).
I have seen https://demo.promlens.com/?l=eF6PYANAlbQ - and I was wondering
if someone could give me some pointers on how I should continue (and if
this is actually a viable option to update labels).
Thanks in advance,
Wiard
--
You received this message because you are subscribed to the Google Groups
"Prometheus Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/prometheus-users/8b10997d-fbd9-460c-9969-a08a014ec3bbn%40googlegroups.com.