Passing Absolute time range in MQL query

  • What Grafana version and what operating system are you using?
    Grafana v8.5.1 Windows10

  • What are you trying to achieve?
    Passing selected Time Range value to MQL query

by MQL do you mean MSSQL?

Hi Mattabrams,
Thank you for replaying back. By MQL

Hello,
I know this thread is old but I’ve been trying to solve this for a long time and just now find a simple solution:

fetch logging_bucket
|metric ‘logging.googleapis.com/user/my_metric
| every mul(1ms,($__to - $__from))
| group_by [ ], percentile(val(),95)

We can use the grafana variables __to and __from to quickly calculate how many milliseconds are in the time range (__range is not available in mql), then we can multiply the duration 1ms by this amount to create a duration which is the same length of the time range.

I haven’t found anyone else mentioning this online, so hopefully this can help someone.

1 Like