Setting up AWS Timestream
Generally two parts are needed for the setup.
- Timestream
- IOT Core
Quick Guide
Got to AWS Timestream, Databases and create a new database.
- Sample database
- Type a Name for the database.
- Choose sample data sets: IoT
- Multi-measure records
- Create database
Open the database, go to table and create a new table.
- Type a table name.
- Choose a Memory store retention time.
- Choose a Magnetic store retention time.
- Optional: Enable magnetic storage writes.
- Create table
Go to IoT Core, Handeln, Regeln and create a new one.
- Type a name for the rule.
- Type a SQL query. SQL Guide
- Add an action.
- Choose database and table.
- Add the dimensions.
- Create or add a Role.
- Create Rule.
- Activate the rule.
Timestream
This is the description on how to set up AWS Timestream.
Database
One database is needed for every fleet.
- Database
- Table
- Rule
For example: If you want to measure with 3 microcontrolers indoor and with 5 outdoor without any connection between indoor and outdoor, it is recommended to create two databases.
Go to Amazone Timestream:
Select database and klick an create database to start creating a new one.
Choose the database configuration as shown.
After clicking on create database you should see an message Succcesfully created database..., if not an error accured and you have to recreate it.
The database is now created with one Table named IoTMulti. This Table is not needed for our setup.
Table
For each device a new table is needed.
- Database
- Table
- Rule
After clicking on the previous created database, go to the tap Tables und klick on Create table.
Type a Name for your Table and choose a time for the memory and the magnetic store.
Click on Create table. Optional: Enable magnetic storage writes.
After klicking on create table you should see a message Succcesfully created table..., if not an error accured and you have to recreate it.
IOT Core
Description on how to setup the IoT Core for your devices. The database and table to which the data should be sent must exist. If not check Chapter Timestream
- Database
- Table
- Rule
Create a Rule
Go to IoT Core.
Select handle, rule and click create.
Give a name to the rule and add a query statement. SQL Guide
SELECT value FROM 'topic/subtopic_for_device_one/#'
Add an Action
This tell AWS where the data should be send to.
Scroll down, select Write a message to timestream table and click on configure action.
Select the database and the table. Add the Dimensions acoording to the sheme:
Dimensionsname | Dimension value |
---|---|
ID | ${MAC_ADRESS} |
Name | ${DEVICE_NAME} |
Sensor Type | ${SENSOR_TYPE} |
SensorID | ${UNIQUE_SENSOR_ID} |
Value | ${VALUE} |
Unit | ${UNIT} |
MeasurementTime | ${TIME} |
Add or create a Role.
Add a Role
Give the role a name.
Click on add action.
Click on create rule.
After clicking on create you should see a message Rule succcesfully created, if not an error accured and you have to recreate it.
Press on the three dots and select activate.
After clicking on activate you should see a message Rule succcesfully activated, if not an error accured and you have to recreate it.
- Database
- Table
- Rule
Setup is done now.