grafanaamazon-timestream

Timestream + Grafana


Today's build is a Grafana Dashboard which is pulling in live data from aws timestream.

Currently, it's showing line graphs which is broken down by hour. The query we use is this:

WITH binned_query AS (
    SELECT
        BIN(time,1h) AS "point",
        x_id  AS "series",
        max(measure_value::bigint) AS "metric"
    FROM $__database.$__table
    WHERE measure_name = 'x'
    AND $__timeFilter 
    GROUP BY BIN(time,1h), x_id order by 1
)
SELECT series, CREATE_TIME_SERIES(point,metric)
FROM binned_query 
GROUP BY series

With the above what is happening is that we are getting data points that are all 1 hour apart. Which is great for some date ranges like 24 hours or 2 days, but when you are looking at 1 hour it would be nice to have it show every minute or 10 minutes.

To accomplish this I see two potential solutions neither of which I've been successful in implementing:

  1. Adjust the query to somehow consider the date-range and change the granularity of the data points.
  2. Some way to add a drop down that would control the granularity of the graphs. This way we could select a date range (say a month) and then I can adjust the line graphs to show 1 min, 5 min, 15 min, 30 min, 1 hr, 3 hr, 6 hr, 12 hr, 24 hr, 48 hr

Any help would be greatly appreciated, been a frustrating morning trying to get this working :)


Solution

  • The $__interval variable might be more useful here instead of 1h.

    This value will change based on the size of the graph/panel and time range. Alternatively if you wanted to keep it at 1h for all graphs and change as you see fit, you could still use this variable and set the interval manually in the panel settings.