# Grafana 11.3: how to make more labels available for alert notification?

**URL:** <https://community.grafana.com/t/grafana-11-3-how-to-make-more-labels-available-for-alert-notification/144468>\
**Category:** Alerting\
**Created:** [February 20, 2025, 10:22am UTC](https://community.grafana.com/t/grafana-11-3-how-to-make-more-labels-available-for-alert-notification/144468 "2025-02-20T10:22:47Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![paxistas](https://avatars.discourse-cdn.com/v4/letter/p/958977/32.png) [@paxistas](https://community.grafana.com/u/paxistas)\
**Post date:** [February 20, 2025, 10:22am UTC](https://community.grafana.com/t/grafana-11-3-how-to-make-more-labels-available-for-alert-notification/144468/1 "2025-02-20T10:22:47Z")

</div>

In alert rule query (Lucene) i have keys “labels.plan\_name”, “labels.sql\_cmd” and “labels.req\_duration”.

I would like to utilize all 3 keys when sending customized alert notifications to MS Teams channel.

However, when i debug the available labels in “index .Labels”, only “labels.plan\_name” is found.

My understanding is that only “labels.plan\_name” is available because thats the only label out of my mentioned 3 which is shown in Grafana Alert rules’ sections B (Reduce) and C (Threshold).

Is there a way to make “labels.sql\_cmd” and “labels.req\_duration” visible in notification template?

---

<div class="post-metadata">

**Author:** ![pepecano](https://sea2.discourse-cdn.com/grafana/user_avatar/community.grafana.com/pepecano/32/40676_2.png) [@pepecano](https://community.grafana.com/u/pepecano)\
**Post date:** [March 4, 2025, 4:43pm UTC](https://community.grafana.com/t/grafana-11-3-how-to-make-more-labels-available-for-alert-notification/144468/2 "2025-03-04T16:43:19Z")

</div>

You are correct.

To be included in [Alert.Labels](https://grafana.com/docs/grafana/latest/alerting/configure-notifications/template-notifications/reference/#alert), `labels.sql_cmd` and `labels.req_duration` should be part of the alert rule final output, the threshold. These are available for use in notification templates.

Alternatively, you can read query labels in alert rule templates via `$labels`.

- [Template annotations and labels | Grafana documentation](https://grafana.com/docs/grafana/latest/alerting/alerting-rules/templates/)
- [Annotation and label template reference | Grafana documentation](https://grafana.com/docs/grafana/latest/alerting/alerting-rules/templates/reference/#labels)

Consider creating a custom annotation (or custom label):

- _my\_sql\_cmd_ → `{{ $labels.sql_cmd }}`

Then, access the custom annotation in the notification template as usual:

```auto
{{ range .Alerts }}
  {{ .Annotations.my_sql_cmd }}
{{end}}

```

Hope it helps!

---

<div class="post-metadata">

**Author:** ![yuriy.tseretyan](https://sea2.discourse-cdn.com/grafana/user_avatar/community.grafana.com/yuriy.tseretyan/32/19714_2.png) [@yuriy.tseretyan](https://community.grafana.com/u/yuriy.tseretyan)\
**Post date:** [March 4, 2025, 7:28pm UTC](https://community.grafana.com/t/grafana-11-3-how-to-make-more-labels-available-for-alert-notification/144468/3 "2025-03-04T19:28:13Z")

</div>

Can you share a screenshot of the query preview? Expressions do not add\drop the labels returned by the data source query. Even math expression when it “unions” two queries picks superset of labels of a dimension.

You need to make sure that the data source query returns labels that you want to include.
