Use data from query for templating

My alert is based on a Postgres query.
Initially I had ID of an error message and the error message, I added another ID field of the relevant entity so now it’s ID, entity ID and error message.

I want to send the entity ID as part of the notifications, is there a way to do that?