Skip to main content
AWS Lambda is a serverless computing service provided by Amazon Web Services (AWS) that allows you to run code without provisioning or managing servers, scaling automatically as needed. This page shows you how to integrate AWS Lambda with to process and store time-series data efficiently.

Prerequisites

To follow the steps on this page:
  • Create a target with Real-time analytics enabled.

    You need your connection details. This procedure also works for .

Prepare your service to ingest data from AWS Lambda

Create a table in to store time-series data.
  1. Connect to your For , open an SQL editor in . For , use psql.
  2. Create a hypertable to store sensor data Hypertables are tables that automatically partition your data by time. You interact with hypertables in the same way as regular tables, but with extra features that make managing your time-series data much easier.
    When you create a using CREATE TABLE … WITH …, the default partitioning column is automatically the first column with a timestamp data type. Also, creates a columnstore policy that automatically converts your data to the , after an interval equal to the value of the chunk_interval, defined through compress_after in the policy. This columnar format enables fast scanning and aggregation, optimizing performance for analytical workloads while also saving significant storage space. In the conversion, s are compressed by up to 98%, and organized for efficient, large-scale queries. You can customize this policy later using alter_job. However, to change after or created_before, the compression settings, or the the policy is acting on, you must remove the columnstore policy and add a new one. You can also manually convert s in a to the .

Create the code to inject data into a service

Write an AWS Lambda function in a Node.js project that processes and inserts time-series data into a .
  1. Initialize a new Node.js project to hold your Lambda function
  2. Install the client library in your project
  3. Write a Lambda Function that inserts data into your Create a file named index.js, then add the following code:

Deploy your Node project to AWS Lambda

To create an AWS Lambda function that injects data into your :
  1. Compress your code into a .zip
  2. Deploy to AWS Lambda In the following example, replace <IAM_ROLE_ARN> with your AWS IAM credentials, then use AWS CLI to create a Lambda function for your project:
  3. Set up environment variables In the following example, use your connection details to add your connection settings to your Lambda function:
  4. Test your AWS Lambda function
    1. Invoke the Lambda function and send some data to your :
    2. Verify that the data is in your . Open an SQL editor and check the sensor_data table:
      You see something like:
You can now seamlessly ingest time-series data from AWS Lambda into .