postgres read query resample time series data for hourly averages
You can use time_bucket function to make it.
Example:
SELECT
  time_bucket('1 hour', &quot;time&quot;) AS hour,
  metric,
  avg(value)
FROM building_data
WHERE kv_tags-&gt;'equip_name' = '[&quot;35201&quot;]' AND 
  m_tags IS NOT NULL
GROUP BY hour, metric
ORDER BY hour limit 1000

Note that I'm simplifying the query and if you want to include kv_tags and m_tags you'll need to also use aggregation functions or add them to the group by clause.