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=${__data.fields.plus}.

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.

I have same problem, i need to calculate time range in my grafana link. The only workaround i found was by-> transform->binary operation and then I subtract - 604799000 in my case 7 days. But i end up with a column with Unix time, wich is very confusing to users and i cannot hide those columns

my time part of link is: from=1694304001000&to=1694304001000

those links:
from=2023-09-20&to=2023-09-22&orgId=1
are ignored by grafana

This documention is misleading because it is not working

Hi @annawojciechowska

Not sure if you are still using Flux or have moved on to l̶e̶s̶s̶ ̶f̶r̶u̶s̶t̶r̶a̶t̶i̶n̶g̶ ̶o̶p̶t̶i̶o̶n̶s̶ greener pastures, but this post explains how to compute the days in the selector time range. You could also modify it to calculate hours, minutes, etc.

This is my solution (Grafana v10.1.2)

http://xxx.xxx.xxx.xx:3000/d/JJ2prQTVz/verbraucher-uebersicht?orgId=1&from=${__value.time}&time=${__value.time}&time.window=172798000

first “&from” then “&time” and then “&time.window”.

“&time.window=172798000” = 23:59:59 hours

3 Likes

Hi @fs1

You saved my time, Thank you!

Hi Grant!
How are you?
Yeah, we dropped Flux since it was not pefrormant enough with Influx 1.8 but I may return to it if I would work with newer version of influx. Thanks!

Hi Anna,

Nice to hear from you. I think there is still considerable interest in Flux, and there is already a movement to keep it going in the OSS community (Flux is dead, Long live Flux(pipe)), but we’ll see what happens.

If you can find me on LinkedIn, please send me a connect request.

Grant

2 Likes