Alerting with non time seires query results

Is it possible to use the result of a database query as the condition for an alert? As shown in my screenshot, I have already written the desired condition in a PostgreSQL query, where I retrieve a table with the fields data_id and last_seen. Grafana automatically treats last_seen as a label. However, I would like to use the query directly as an alert and return the id and last_seen in the description.


The current situation is that as time progresses, the last_seen value keeps increasing, resulting in new labels being added continuously. This prevents the pending alert instances from being sent out.

I would like to know if it’s possible to directly use the query result as the condition and content of the alert.