Using a timestamp as dashboard variable in a Loki query

Hi! I am new to Grafana and having trouble figuring this out.

I have set up Grafana alerting to notify about errors in kubernetes pod logs that I get from Loki. I get the alert notifications in MS Teams.

I am working on a custom notification template and would really like to have custom URL that would take me to a dashboard that shows logs in a context, 5 minutes before and after a given timestamp. ( not relative to current time, but relative to provided timestamp)

I am thinking of using {{ .StartsAt.Unix }} unix timestamp value from the Grafana alert and passing it as a custom Dashboard variable via the URL. Then the $timestamp would be used in a Loki query in the Dashboard that generates the list of logs.

Would this be possible?

Currently I am experimenting with the variables and custom log dashboard, but stuck with the next steps and not even sure if this can be done in this way. Would appreciate any input. Thanks!

I am using Grafana 9.3 at the moment, but can upgrade.

I found a solution myself after a few hours. Turns out there is a URL parameter to control time range and conveniently it takes unix timestamp as a value so we can use {{ .StartsAt.Unix }} but need to add 000 since it needs it to be in ms.

From the docs:

time and time.window - defines a time range from time-time.window/2 to time+time.window/2. Both params should be specified in ms. For example ?time=1500000000000&time.window=10000 will result in 10s time range from 1499999995000 to 1500000005000

Docs: Manage dashboard links | Grafana documentation