# Timestream

Source: /aws/services/timestream-query/

## Introduction

LocalStack contains basic support for Timestream time series databases, including these operations:

* Creating databases
* Creating tables
* Writing records to tables
* Querying timeseries data from tables

The supported APIs are available on our API Coverage Page ([Timestream Query](#api-coverage-timestream-query)/[Timestream Write](#api-coverage-timestream-write), which provides information on the extent of Timestream integration with LocalStack.

## Getting Started

The following example illustrates the basic operations, using the [`lstk aws`](/aws/developer-tools/running-localstack/lstk/cloud-and-iac-commands/#aws) command line.

First, we create a test database and table:

```bash
lstk aws timestream-write create-database --database-name testDB
lstk aws timestream-write create-table --database-name testDB --table-name testTable
```

We can then add a few records with a timestamp, measure name, and value to the table:

```bash
lstk aws timestream-write write-records --database-name testDB --table-name testTable --records '[{"MeasureName":"cpu","MeasureValue":"60","TimeUnit":"SECONDS","Time":"1636986409"}]'
lstk aws timestream-write write-records --database-name testDB --table-name testTable --records '[{"MeasureName":"cpu","MeasureValue":"80","TimeUnit":"SECONDS","Time":"1636986412"}]'
lstk aws timestream-write write-records --database-name testDB --table-name testTable --records '[{"MeasureName":"cpu","MeasureValue":"70","TimeUnit":"SECONDS","Time":"1636986414"}]'
```

Finally, we can run a query to retrieve the timeseries data (or aggregate values) from the table:

```bash
lstk aws timestream-query query --query-string "SELECT CREATE_TIME_SERIES(time, measure_value::double) as cpu FROM testDB.timeStreamTable WHERE measure_name='cpu'"
```

```bash title="Output"
{
  "Rows": [{
    "Data": [{
      "TimeSeriesValue": [{
        "Time": "2021-11-15T14:26:49",
        "Value": {
            "ScalarValue": 60
        }
    },
...
```

## Resource Browser

The LocalStack Web Application provides a Resource Browser for managing Timestream databases.
You can access the Resource Browser by opening the LocalStack Web Application in your browser, navigating to the **Resources** section, and then clicking on **Timestream** under the **Database** section.

![Timestream Resource Browser](/images/aws/timestream-resource-browser.png)

The Resource Browser allows you to perform the following actions:

* **Create Database**: Create a new Timestream database by clicking on the **Create Database** button and providing a name for the database among other optional details.
* **Create Table**: Create a new Timestream table by clicking on the **Create Table** button in the database view and providing a name for the table among other optional details.
* **Run Query**: Run a Timestream query by clicking on the **Run Query** button in the table view and providing a query string.
* **View Database/Table Details**: Click on a database or table to view its details, including the schema, retention policy, and other metadata.
* **Delete Database/Table**: Delete the Timestream database/table by selecting it and clicking on the **Actions** button followed by **Remove Selected** button.

## Current Limitations

LocalStack's Timestream implementation is under active development and only supports a limited set of operations, please refer to the API Coverage pages for an up-to-date list of implemented and tested functions within [Timestream-Query](#api-coverage-timestream-query) and [Timestream-Write](#api-coverage-timestream-write).

If you have a usecase that uses Timestream but doesn't work with our implementation yet, we encourage you to [get in touch](https://localstack.cloud/contact/), so we can streamline any operations you rely on.

## API Coverage (Timestream Query)


### Timestream Query API coverage

Source service: `timestream-query`. 11 of 15 tracked operations are implemented.

Service documentation: /aws/services/timestream-query/
License availability: available starting with the Ultimate plan. See /aws/licensing/ for current plan details.

| Operation | Status |
| --- | --- |
| CancelQuery | Not implemented |
| CreateScheduledQuery | Implemented |
| DeleteScheduledQuery | Implemented |
| DescribeAccountSettings | Not implemented |
| DescribeEndpoints | Implemented |
| DescribeScheduledQuery | Implemented |
| ExecuteScheduledQuery | Implemented |
| ListScheduledQueries | Implemented |
| ListTagsForResource | Implemented |
| PrepareQuery | Not implemented |
| Query | Implemented |
| TagResource | Implemented |
| UntagResource | Implemented |
| UpdateAccountSettings | Not implemented |
| UpdateScheduledQuery | Implemented |

## API Coverage (Timestream Write)


### Timestream Write API coverage

Source service: `timestream-write`. 15 of 19 tracked operations are implemented.

Service documentation: /aws/services/timestream-query/
License availability: available starting with the Ultimate plan. See /aws/licensing/ for current plan details.

| Operation | Status |
| --- | --- |
| CreateBatchLoadTask | Not implemented |
| CreateDatabase | Implemented |
| CreateTable | Implemented |
| DeleteDatabase | Implemented |
| DeleteTable | Implemented |
| DescribeBatchLoadTask | Not implemented |
| DescribeDatabase | Implemented |
| DescribeEndpoints | Implemented |
| DescribeTable | Implemented |
| ListBatchLoadTasks | Not implemented |
| ListDatabases | Implemented |
| ListTables | Implemented |
| ListTagsForResource | Implemented |
| ResumeBatchLoadTask | Not implemented |
| TagResource | Implemented |
| UntagResource | Implemented |
| UpdateDatabase | Implemented |
| UpdateTable | Implemented |
| WriteRecords | Implemented |
