Is it correct that the $__interval_ms varaible can’t be used with MySQL?
I’m using MySQL as a datasource, and just discovered the templating section in the docs.
There are 2 variables described for grouping based on timerange and and pixel width: $__interval and $__interval_ms.
Sadly it seems like only $__interval can be used in the MySQL query. Trying to use the $__interval_ms variable throws an error that looks like the variable couldn’t be found.
I couldn’t figure out how to convert the timestring values from $__interval (1m, 2d, …) to seconds on the fly in the query.
I need a value in seconds for grouping (as UNIX_TIMESTAMP is also in seconds), which would work fine with $__interval_ms:
SELECT
UNIX_TIMESTAMP(TIMESTAMP) as time_sec,
AVG(VALUE) as value,
DEVICE as metric
FROM history
WHERE READING="temperature AND DEVICE=“Thermometer” AND $__timeFilter(TIMESTAMP)
GROUP BY UNIX_TIMESTAMP(TIMESTAMP) DIV ($__interval_ms / 1000)