I have a grafana dashboard that is connected to a PostgreSQL database. I understand how to change the absolute time range to show a time range on a graph, but am wondering if it is possible to change my query to reflect that for a total.
For example, I have a query that gets the total number of rows:
SELECT
COUNT(*) as "Total Number of Rows:"
FROM mytable
Is it possible to show the total number of rows for the specified time in grafana (ex. past 30 days, past 6 hours, etc)?
Thanks!
You have to modify your query as follow:
SELECT
$__time(time_column),
count(*) as "Total Number of Rows:"
FROM
mytable
WHERE
$__timeFilter(time_column)
GROUP BY time_column
In this way Grafana will filter using $__timeFilter on the specified time_column