Thanks Brain.

That worked like a charm. 

On Tuesday, 5 October 2021 at 10:35:48 UTC+2 Brian Candler wrote:

> >         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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/prometheus-users/695ed8ad-a0f2-44d4-823c-11ff767aa579n%40googlegroups.com.

Reply via email to