AWS Timestream / Grafana Querying

1.7k Views Asked by At

I'm developing an AWS timestream/Grafana dashboard, but I have some problems. I created the database and table in timestream and then in grafana I connected to the timestream datasource.

Now I want to do a dashboard with queries or transformations to display a formula; in my database, I have 2 measures "A" and "B", and I want to display the result of the following: (Dif(A) / Dif(B));

I read the documents but I didn't succeed at doing that.

1

There are 1 best solutions below

0
On

Do the two measures A and B have events with the same timestamp? What does Dif(A) mean? A sample query to get the result of A/B where every event of A and B have the same timestamp and is of type double is below

WITH cte1 AS (
    SELECT time, measure_value::double as value_a
    FROM <db>.<table>
    WHERE time > ago(1h) AND measure_name = 'A'
), cte2 AS (
    SELECT time, measure_value::double as value_b
    FROM <db>.<table>
    WHERE time > ago(1h) AND measure_name = 'B'
)
SELECT cte1.time, cte1.value_a / cte2.value_b
FROM cte1 INNER JOIN cte2 ON cte1.time = cte2.time