How to query Timestream for several different measure_name and their values

0

Hi,

Timestream is great in many ways, but seems to be hard/different to work with if you want to query several different measurements in the same query. This is because of the "flat" data model that Timestream uses.

If we use the example dataset found in the documentation at
https://docs.aws.amazon.com/timestream/latest/developerguide/sample-queries.devops-scenarios.html

How can I write a query that returns the four columns
time,
hostname,
(measure_value::double for) cpu_utilization and
(measure_value::double for) memory_utilization?

The CREATE_TIME_SERIES function only seems to work with one measure_name?

Thanks.

Terje
已提问 3 年前3105 查看次数
1 回答
0

To answer my own question:

One way to do this is with a following type of query:

-- Get data points for both CO2 and humidity
SELECT
time,
MAX(if(measure_name = 'CO2', measure_value::double)) AS CO2_ppm,
MAX(if(measure_name = 'humidity', measure_value::double)) AS humidity_percent
FROM "MyTimestreamDB"."myTable"
WHERE
time >= ago(10m)
AND measure_name IN ('CO2', 'humidity')
AND deviceId='6a087171-400c-4851-a82b-ceab383b421c'
GROUP BY time
ORDER BY time DESC

Terje
已回答 3 年前

您未登录。 登录 发布回答。

一个好的回答可以清楚地解答问题和提供建设性反馈,并能促进提问者的职业发展。

回答问题的准则