Accessing Query Expression Results for Custom Notification Templates in Managed Grafana Alerts

I’m currently facing an issue with accessing the results of a Query Expression within my custom notification template for Managed Grafana alerts. Despite configuring everything correctly (to my knowledge), when I try to use the template variable {{ .Values.value }} to display the query result value in my alarms, it consistently returns 0, indicating that the actual value is not being fetched or accessed correctly. Attached is a screenshot of the Metric expression setup for context.

I have already invested a considerable amount of time trying to troubleshoot and resolve this issue but to no avail. If anyone here has encountered a similar problem or has insights on how to properly access and use Query Expression results in custom notification templates for alerts in Managed Grafana, your guidance would be greatly appreciated. Below is a snippet of how I’m attempting to access the value in the template:

*Value*: {{ .Values.value }}

Thank you in advance for your help and suggestions!

so B value(s) will be {{ index $values "B" }} or {{ $values.B }}.

But this is not a task for notification template. You should use it in the alert annotation, e.g. meaningful description:

Pod: {{ $labels.container }} in namespace: {{ $labels.namespace }} on cluster: {{ $labels.kubernetes_cluster }} has high CPU utilization: {{ humanize $values.B.Value }}%

and notification template just use that annotation.

$values does not work

Tried that already and got an error.

Error: failed to save and apply Alertmanager configuration: template: slack:20: undefined variable “$values”

Also, this notification is not restricted to a single metric it is meant to work for multiple data sources like Cloudwatch, Prometheus, and Loki.

As I said: that’s for annotation, not for notification template.