We can use the AWS SDK to access Timestream outside of the console - ie. to serve the data so that the dashboard team is able to get and display data for the dashboard. Specifically, Timestream supports two SDKS: the Write SDK and the Query SDK (see Using the AWS SDKs ).
- used to perform CRUD operations
- insert timeseries data into Timestream
- query existing data that is already stored in Timestream
We used the node.js SDK in this iteration, but there are other SDKs available in different languages. Timestream documentation provides a link to this sample repo with a working sample. A barebone repo with just the code required for the EMA project can also be found on github - link here. For both examples, ensure that you have configured your AWS Credentials (links below).
The general steps are listed below, with links to the detailed AWS documentation pages.
- Install node if not yet installed
- In a new node.js app, install the AWS SDK for JS with your preferred package manager.
- Configure AWS Credentials
- Create Package.json as needed (or just install the required packages if using samples)
- Write the node.js code, which includes the new instances of the Timestream clients for both Write and Query SDKs, SQL queries to query the specific data you’re looking for, and the code to use the functions provided by the SDKs to retrieve data from the database (docs).