# Different alert messages for nodata

**URL:** <https://community.grafana.com/t/different-alert-messages-for-nodata/134661>\
**Category:** Alerting\
**Tags:** templating, alerting\
**Created:** [October 21, 2024, 1:03am UTC](https://community.grafana.com/t/different-alert-messages-for-nodata/134661 "2024-10-21T01:03:46Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![duncanwhit](https://sea2.discourse-cdn.com/grafana/user_avatar/community.grafana.com/duncanwhit/32/49719_2.png) [@duncanwhit](https://community.grafana.com/u/duncanwhit)\
**Post date:** [October 21, 2024, 1:03am UTC](https://community.grafana.com/t/different-alert-messages-for-nodata/134661/1 "2024-10-21T01:03:46Z")

</div>

How can I provision an alert rule/contact point/notification policy so that the message is different when the alert status is ‘nodata’. For example the message for an app with high memory use would be something like:  
“The application is using 10GB of memory”

…but if the alert query returns nothing the message should instead be something like:  
“No memory data available for the application!”

When I set the alert rule’s noDataState to “NoData”, no alert is generated.

When I set the alert rule’s noDataState to “Alerting”, an alert is generated but the labels and values are identical to the high memory case so the it doesn’t seem possible to distinguish between the two to send the appropriate message text.

---

<div class="post-metadata">

**Author:** ![jangaraj](https://sea2.discourse-cdn.com/grafana/user_avatar/community.grafana.com/jangaraj/32/39197_2.png) [@jangaraj](https://community.grafana.com/u/jangaraj)\
**Post date:** [October 21, 2024, 1:21am UTC](https://community.grafana.com/t/different-alert-messages-for-nodata/134661/2 "2024-10-21T01:21:35Z")

</div>

> [@duncanwhit](#):
>
> When I set the alert rule’s noDataState to “Alerting”, an alert is generated but the labels and values are identical to the high memory case so the it doesn’t seem possible to distinguish between the two to send the appropriate message text.

Yes, but [State and health of alerts | Grafana documentation](https://grafana.com/docs/grafana/latest/alerting/fundamentals/alert-rule-evaluation/state-and-health/#special-alerts-for-nodata-and-error)

> `alertname`: Either `DatasourceNoData` or `DatasourceError` depending on the state.

So you can use notification policy for custom routing based on alertname. Probably you can use it also in the notification template to customize message.

---

<div class="post-metadata">

**Author:** ![duncanwhit](https://sea2.discourse-cdn.com/grafana/user_avatar/community.grafana.com/duncanwhit/32/49719_2.png) [@duncanwhit](https://community.grafana.com/u/duncanwhit)\
**Post date:** [October 21, 2024, 9:52pm UTC](https://community.grafana.com/t/different-alert-messages-for-nodata/134661/3 "2024-10-21T21:52:50Z")

</div>

Thanks, yes after I changed the alert rule config to have `noDataState: NoData` it generated an alert with `alertname: DatasourceNoData` in GroupLabels, CommonLabels, and Alerts \> Labels.
