3.1 Data Set
Create a data set
You retrieve data from a data store by creating a SQL dataset or a container dataset. AWS IoT Analytics can query the data to answer analytical questions.
- Navigate to the AWS IoT Analytics console.
- In the left navigation pane, navigate to Datasets
- Choose Create a data set
- Select Create SQL
- ID:
<yourname>_streamdataset
- Select data store source: yourname-iotastore, this datastore is associated with S3 bucket containing the transformed data created in step 2.4.
- Click Next
- Enter the following SQL statement:
SELECT * FROM <yourname>_iotastore ORDER BY timestamp DESC LIMIT 1000. Click Test query to see if results are returned!
- Click Next
- For the Data selection filter, select None. Click Next.
- For the schedule, select the following:
- Frequency: Every 5 minute
- Minute of hour: 0
- Click Next
- Keep all other options as default and click Next until you reach ‘Configure dataset content delivery rules - optional’
- Under Add Rule, Choose Deliver result to S3 and click Add.
- Enter the following options:
- S3 bucket: select the S3 bucket that ends with ‘-dataset’.
- Bucket Key Expression:
dataset/mydataset/!{iotanalytics:scheduleTime}/!{iotanalytics:versionId}.csv
- IAM Role: Create New role that allows IoT Analytics to put data to S3 and give your new IAM Role a name, for example
<yourname>-iot-analytics-dataset-role.
- Click Next and then Click Create data set to finalize the creation of the data set.
The dataset has now been configured to query the last 1000 records and update every five minutes. *NOTE: This is used to increase the amount of data that we will visualize, but is not always the correct method. Another option for updating the dataset is using Delta Time Windows.