DEV Community

Blitz
Blitz

Posted on

Timestream Data Design & Ingestion

After the first introduction to AWS Timestream, let's get into it.

Let's first spin some data. As an example, let's assume that you have an IoT device that will send you the following event every so often:

{
    "event_id": 123456,
    "created_time": 1604355422089,
    "device_id": "test_device",
    "usecase": "retail",
    "device_battery": 80,
    "temperature": 60.34,
    "weight": 20
}
Enter fullscreen mode Exit fullscreen mode


`

So how do you get this into AWS Timestream?

As with every database, you start with your schema.
AWS Timestream splits its data into measures and dimensions. How should we break our sample event into these categories?
As the docs say, fields that "describe" the data should be the dimensions. In the event above, I would see the event_id, device_id, and usecase as the dimensions. Conversely device_battery, temperature and, weight would be the measures. And created_time as the time dimension of course.

The weird thing about AWS Timestream is that you will add this data as 3 rows, as it contains three measurements:

event_id device_id usecase measure_value::BIGINT measure_value::DOUBLE measure_name time
123456 test_device retail 80 device_battery 1604355422089
123456 test_device retail 60.34 temperature 1604355422089
123456 test_device retail 20 weight 1604355422089

Top comments (0)