Hello Grafana Community,
I’m currently working with a PostgreSQL database that contains 5 tables named: wmz_a
, wmz_b
, wmz_c
, wmz_d
, and wmz_e
. Each of these tables shares the same structure, hosting 5 columns: timestamps
, h
, c
, q
, and e
.
To streamline my Grafana dashboard, I’ve created a custom variable named heat_meters
to dynamically select among these tables (wmz_a
, wmz_b
, wmz_c
, wmz_d
, and wmz_e
). My goal is to utilize this variable within my SQL queries to fetch data accordingly.
However, I’m encountering difficulty in correctly formulating the SQL query to dynamically select the table name based on the heat_meters
variable. My current SQL query structure is as follows:
SELECT
timestamps as time,
h as heat,
FROM ‘$heat_meters’
ORDER BY timestamps
Despite my efforts, the dynamic table selection is not functioning as expected. I would deeply appreciate any guidance, tips, or solutions on how to correctly implement this dynamic selection within my SQL query for Grafana. Your assistance will be invaluable to me.
Thank you in advance for your support and contributions!