Skip to content

Instantly share code, notes, and snippets.

@h3xagn
Created May 24, 2025 15:00
Show Gist options
  • Select an option

  • Save h3xagn/29566e19bb63cc82a87b598e1c068782 to your computer and use it in GitHub Desktop.

Select an option

Save h3xagn/29566e19bb63cc82a87b598e1c068782 to your computer and use it in GitHub Desktop.
Data queries for Grafana dashboard tiles
-- TimeScaleDB
SELECT
time_bucket('180 seconds', bucket) AS agtime,
AVG(avg) as "lab_indoor_temp"
FROM
timeseries_60s
WHERE
$__timeFilter("bucket") AND
tagname = 'lab_indoor_temp'
GROUP BY agtime
ORDER BY agtime ASC
-- InfluxDB
SELECT
DATE_BIN(INTERVAL '180 seconds', time) AS time,
avg(value) AS 'lab_indoor_temp'
FROM homedb
WHERE
time >= $__timeFrom
AND time <= $__timeTo
AND sensor = 'lab_indoor_temp'
GROUP BY 1
ORDER BY 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment