Hello,
I installed grafana, but my sql skills are way below the level of the presentation in the documentation regarding my “issue”. Please excuse me if there happens to be a dedicated feature/chapter which exactly would do this. I simply can’t understand/find it there.
I connected my sqlite db file through the sqlite datasource and doing a simple single query of my table like;
SELECT DateTimeStamp, Temperature FROM sensordata
It’s a timeseries table and the DateTimeStamp column is set as a time formatted column.
The table is starting to be big and the query time is taking longer and longer, which is normal because i am doing a complete query of the table.
My question is if there is a way to connect or corelate the relative or absolute timerange
dropdown list elements to query only the selected time range and don’t do a full query then jump to that time range.
I searched for keywords like dynamic, time, range, query on google and here but nothing that i would understand came up.
Thank you kindly and have a nice evening if applies.
The kind of functionality you’re talking about – creating dynamic queries based on a time range – is totally possible in other, more robust SQL databases like MySQL and Postgres. The typical method uses macros, I believe. Here are the macros for the MySQL datasource plugin.
For instance, here is a query I have using that plugin:
SELECT
UNIX_TIMESTAMP(TIMEST) as time_sec,
VARIABLE_VALUE+0 as value,
VARIABLE_NAME as metric
FROM my2.status
WHERE $__timeFilter(TIMEST)
AND variable_name in ('THREADS_CONNECTED', 'THREADS_RUNNING')
ORDER BY TIMEST ASC
my god, i envy people like you (decoding “kitchen language” and solving the problem after reading the documentation, not to mention you dont even use sqlite i assume).
thank you btw i already changed from sqlite to influxdb for this exact reason. Since influx natively does dynamic query after i link my db everything works like a charm.
Wise decision, switching to influx. I think you’ll find much more support and functionality using that db!
There are some influx wizards (not me, unfortunately!) lurking in this forum, so as you continue to explore that product, don’t hesitate to keep posting questions