Skip to content

WriteRecords

Source: src/AWS/Timestream/WriteRecords.ts

Runtime binding for timestream-write:WriteRecords — ingest time-series records into a Timestream Table.

Bind the operation to a table inside a function runtime to get a callable with DatabaseName and TableName injected automatically; you only supply the Records (and optional CommonAttributes). For high-volume streaming ingestion prefer the batching RecordsSink.

Provide Timestream.WriteRecordsHttp on the Function to implement the binding.

// init — bind the operation to the table
const writeRecords = yield* Timestream.WriteRecords(table);
// runtime — ingest a record
const result = yield* writeRecords({
Records: [
{
Dimensions: [{ Name: "host", Value: "web-1" }],
MeasureName: "cpu",
MeasureValue: "42.5",
MeasureValueType: "DOUBLE",
Time: `${Date.now()}`,
TimeUnit: "MILLISECONDS",
},
],
});
// result.RecordsIngested reports how many records landed