Grafana Alerting Templating Labels

Hi All!

So I was wondering if anyone knows how to input logic into the grafana labels templates?

The reason i am asking is because i want to set labels based on thresholds, so from one rule i can say severity = notify, warning, critical. To do this i wanted to put some logic in the label template. I found in the documentation we can do this :

{{ if $values.B }}{{ $labels.instance }} has a 95th percentile request latency above 1s: {{ $values.B }}){{ end }}

But wanted to say something like {{ if $values.B == 5 }}{{this_value}}{{ else }}{{this_othervalue}}{{end}}

Thanks!

Bump. Does anyone have any tips?

Thanks!

did you get any answers?

Looking for a solution for the same thing. is it possible?

I did have a couple meetings with some of the grafana folks on this.

It seems they can only recommend multiple rules for multiple thresholds. On the flip side apparently the underlying query is only executed once even though you evaluate multiple rules.

Looking into automation around bulk creating these rules via grafana rest api or something similar.