Table
Source:
src/AWS/Timestream/Table.ts
An Amazon Timestream for LiveAnalytics table — a time-series store inside a
Database.
Table owns the table’s lifecycle and its mutable configuration: memory and
magnetic store retention, magnetic store write behavior, and tags. A table
name is auto-generated from the app, stage, and logical ID unless you provide
one.
Creating Tables
Section titled “Creating Tables”Basic Table
import * as Timestream from "alchemy/AWS/Timestream";
const database = yield* Timestream.Database("Metrics");const table = yield* Timestream.Table("Cpu", { databaseName: database.databaseName,});Table with Retention Tuning
const table = yield* Timestream.Table("Cpu", { databaseName: database.databaseName, retentionProperties: { memoryStoreRetention: "24 hours", magneticStoreRetention: "365 days", },});Writing Points
Section titled “Writing Points”// initconst writeRecords = yield* Timestream.WriteRecords(table);
return { fetch: Effect.gen(function* () { // runtime yield* writeRecords({ Records: [ { Dimensions: [{ Name: "host", Value: "web-1" }], MeasureName: "cpu", MeasureValue: "42.0", MeasureValueType: "DOUBLE", Time: `${Date.now()}`, TimeUnit: "MILLISECONDS", }, ], }); return HttpServerResponse.text("ok"); }),};