Different alert messages for nodata

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.

Yes, but State and health of alerts | Grafana documentation

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.

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.