I am currently working with Grafana and trying to create a link that redirects to another dashboard with a specified time range, which is 5 minutes before and after a certain timestamp. I have the timestamp details in a formatted string (e.g., "2023-09-20 16:00:20") and I am trying to convert it to epoch milliseconds to use in a URL parameter (like 1695218420000, which seems to be in UTC+02:00).
The time from the log entry is captured in a variable ${__data.fields.Time} which gets substituted into the URL. However, Grafana seems to be unable to interpret the formatted date-time string in the URL parameters for 'from' and 'to' fields to set a correct time range.
For example, using the link structure: https://localhost:8443/d/XtPc_riIk/fehler-kontrolle?orgId=1&var-hostname=${__data.fields.hostname}&from=${__data.fields.Time:epochmillis-300000}&to=${__data.fields.Time:epochmillis+300000} translates to: https://localhost:8443/d/XtPc_riIk/fehler-kontrolle?orgId=1&var-hostname=mrs2-11&from=2023-09-19%2006:55:49&to=2023-09-19%2006:55:49 which is not the correct format for the 'from' and 'to' parameters in Grafana.
I attempted to use the epochmillis function to convert the formatted date-time string to epoch milliseconds directly within the URL, expecting Grafana to be able to interpret and translate it into the correct time range. Additionally, I tried adding and subtracting 300000 milliseconds (5 minutes) to create a time range around the timestamp. However, Grafana seems to not be interpreting the formatted date-time string correctly and is not converting it to epoch milliseconds as expected.
As @markalex recommended, I employed transformations to introduce additional columns with dates. Regrettably, concealing them disrupts the link functionality, so I have to retain their visibility.