How to use the payload's timestamp?

0

We receive JSON-encoded data like
{"data":\[{"n":1234,"s":"abcd","t":1630543365507,"x":0.5678}],"type":"sample"}
where "t" is the (UNIX epoch milliseconds) time at which this sample was collected.
How can we use that as the Timestream timestamp?

Timestream's Product FAQ (https://aws.amazon.com/timestream/faq/?loc=5#Data_ingestion) says it "uses the timestamp of the time series event being written into the database."
The Developer Guide (https://docs.aws.amazon.com/timestream/latest/developerguide/concepts.html) says "Timestamp - Indicates when a measure was collected for a given record."
The Developer Guide (https://docs.aws.amazon.com/timestream/latest/developerguide/data-ingest.html) says "Data ordered by timestamps has better write performance"

What do the ingested data's timestamps matter, if Timestream will apply timestamps corresponding to the time they're written into the database?

A Timestream developer forum thread (https://forums.aws.amazon.com/thread.jspa?threadID=329388) refers to an IoT developer forum thread (https://forums.aws.amazon.com/thread.jspa?messageID=959502) in which the IoT feature Timestream Rule Action (https://docs.aws.amazon.com/iot/latest/developerguide/timestream-rule-action.html) was implemented (according to @manbeenaws) to specify an arbitrary value (i.e. a timestamp specified in the MQTT payload) as the Timestream timestamp.

Is there a way to use a payload value as the Timestream timestamp, if the data don't arrive via IoT?

Edited by: bobsut on Sep 1, 2021 11:44 AM

Edited by: bobsut on Sep 1, 2021 12:35 PM

profile picture
bobsut
已提問 3 年前檢視次數 459 次
1 個回答
0

You can use the timestamp from your data sample when using the WriteRecords API to write data to Timestream. For each record in your WriteRecords request, you set the "Time" parameter as the timestamp for the event (in your case, to the value of "t"). Timestream uses this value as the timestamp for the event.

More information on the WriteRecords API: https://docs.aws.amazon.com/timestream/latest/developerguide/API_WriteRecords.html
and on the Record type: https://docs.aws.amazon.com/timestream/latest/developerguide/API_Record.html

I hope this helps with your use case. Thanks for your interest in Amazon Timestream!
Audrey

AWS
已回答 3 年前

您尚未登入。 登入 去張貼答案。

一個好的回答可以清楚地回答問題並提供建設性的意見回饋,同時有助於提問者的專業成長。

回答問題指南