Where to specify my labels with grafana alerting prometheus metrics

Hi everyone, my compagny stated to use Grafana, Loki and Prometheus for monitoring.
All was going grate until I came across the Alerting part.
After long search on the forum and git I found most of what I needed.
Thanks to a moderator posting on this topic (: How To Use Alert Message Templates in Grafana) I manage to get this output in my Slack channel :
image
This is the template :
{{ with $values }}
{{ range $k, $v := . }}
Host: {{$v.Labels.Host}}
Variable: {{$v.Labels.variable}}
Seuil d’alerte: {{ $v }}
{{ end }}
{{ end }}

My question is : Where do I declare Variable = CPU ( for this alert) and Host = Hostname of my device.

Grafana is on version 8.5.3.

Thanks for help !

Welcome to the Grafana forum.

On your Edit Alert Rule screen, can you click Preview Alerts and paste the full text of what you see? For example:


[ var='B' labels={Tank=A5} value=9 ]

1 Like

Hi, thanks for your time, there is my Preview Alerts

[ var='X0' metric='Value' labels={} value=2.421758569299553 ], [ var='X1' metric='Value' labels={} value=35.22438200320917 ]

Sorry for the delay in responding.

From your Preview Alerts output that you shared above, the labels have no content, which is why your Slack alert shows this:

image

Can you share your full Prometheus queries that you use to generate the alerting values?

I see you posted your question to another thread, so go ahead and reply there to my question above about the complete query (incl the reduce function, the alerting expression, etc.).