>         severity: '{{ .CommonLabels.severity }}'

Ah right, so this is actually a templating problem.  You want to have a 
default value when *expanding the template*.

I don't do much with go templating, but it looks like the "or" function is 
what you want:
https://pkg.go.dev/text/template#hdr-Functions

That page is linked 
from 
https://prometheus.io/docs/prometheus/latest/configuration/template_reference/
Googling for "go template examples" may help, which includes
https://play.golang.org/p/Uzpwm1Wt_E
and I also found an online tester:
https://camlittle.com/go-template-validation

Try these:

severity: '{{ or .CommonLabels.severity "error" }}'

severity: '{{if .CommonLabels.severity}}{{ .CommonLabels.severity }}{{ else 
}}error{{ end }}'

> When the timeseries doesn't have any labels, how does the grouping of 
these alerts are handled. 

You can add extra labels in your alerting rule.

-- 
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 prometheus-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/prometheus-users/c2a0bcd2-23b9-4649-9fe3-c96979be3bb6n%40googlegroups.com.

Reply via email to