Data link ${__value.time}

I am trying to create data link and use ${__value.time}

URL format is http://localhost/from=${__value.time}&to={???}

Can I subtract or add time to variable ${__value.time}?

For example : to=${__value.time}+5m

im currently having the same problem. have you found anything so far?

Not yet. Tried many things with {__value.time} but nothing worked.
I am now using {{_from.time}} and {{_to.time}},which basically takes your panels interval.

i found a way around it. for me the timestamp is called UNIX_UTC_00 and i se this one as time UNIX_UTC_00 AS time. then i call all the info i want. and then i call the UNIX_UTC_00 again.

the difference is that the second time i call like this: UNIX_UTC_00 * 1000 - 60000 AS minus and UNIX_UTC_00 * 1000 + 60000 AS plus.

this gives me 1 minute before and 1 minute after the datas timeframe.

i then call them in the data link like this: <websitelink>&from=${__data.fields.minus}&to=${}.

hope this helps you a bit.

1 Like

Thanks for the update.
what are the steps to declare variable (ex. minus and plus) in grafana ?

i use UNIX_UTC_00 as my “time”. so i declare plus and minus in the same sql query. this way they are linked to the same time that the message has. i do *1000 so that it works with the time Grafana uses. for examle unix would display the time as 1645431252 in my database. but Grafana would need it as 1645431252000. this is because they use unix in milliseconds.

and the +60000 and -60000 are just so it it adds and subtracts 1 minute of time. after i do that i hide the field so i can use the data but it doesnt display. you can do that in the Overrites tab.

its a bit of a work around. but i hope this explains how i do it and how it works. if not i would be happy to type it out in more detail.

1 Like

ok. My data source is Prometheus so can’t use sql query. Need to check if this can be done through PromQL. Thanks for your help.