How to create a IoT Core Rule to save a JSON list of objects to timestream

0

Hi,

I run a RaspberryPi with different temperature sensors on it. I collect all sensor data and send them to IoT Core. In the MQTT Test-Client I can also subscribe to the message and see the following output:

[ { "sensor_id": "28-011921dac0de", "value": 20.937 }, { "sensor_id": "28-3ce10457469c", "value": 59.5 }, { "sensor_id": "28-011921d74ee8", "value": 46.812 }, { "sensor_id": "28-3ce104579319", "value": 45.375 } ]

  1. Is it a bad idea to send all sensore datas in one message?
  2. How do I have to define the rule to send this message to TimeStream? At the end I want to visualize/analyze each temperature value.

Thank you

질문됨 일 년 전566회 조회
3개 답변
1

Hi Philipp,

  1. It is not a bad idea, quite the contrary. By batching the readings from multiple sensors in one single message you are reducing the amount of message considerably
  2. The IoT Rule Timestream action does not support inserting records with different dimensions (in your case the sensor_id would be a dimension), but you can send the message payload to a Lambda function and have the Lambda function write the records in Timestream. You can have a look at this repo on how to write such Lambda function: https://github.com/massi-ang/amazon-timestream-app
AWS
전문가
답변함 일 년 전
0

Regarding the first question, there is no right way to send the data, it all depends on your use case and your expected results. Regarding the second question. Check this tutorial about Ingesting Data into Amazon Timestream with AWS IoT Core.

AWS
David C
답변함 일 년 전
  • I added a key to my array now:

    { "sensors": [ { "sensor_id": "28-011921dac0de", "value": 58.937 }, { "sensor_id": "28-3ce10457469c", "value": 59.562 }, { "sensor_id": "28-011921d74ee8", "value": 58.0 }, { "sensor_id": "28-3ce104579319", "value": 46.375 } ] }

    My SQL query looks like that now: SELECT (SELECT sensor_id, value from sensors) as output FROM 'test/testing'

    As a dimension I selected "sensor_id": $(sensor_id) but It is just writing into timestream the string $(sensor_id)

    Why?

0

It seems to be impossible with just a SQL statement:

See here for more details: https://stackoverflow.com/questions/74090199/aws-iot-rule-sql-republish-get-thing-name-as-json-object-key

답변함 일 년 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인