AWS Lambda Extension that uses the Lambda Telemetry API to forward logs to a Better Stack HTTP source.
In order to use the extension you must first build and deploy it into your AWS infrastructure:
$ git clone git@github.com:logtail/logtail-lambda-extension.git
$ cd logtail-lambda-extension
$ pnpm install
$ pnpm run build
$ aws lambda publish-layer-version \
--layer-name "logtail-lambda-extension" \
--zip-file "fileb://./dist/extension.zip" \
--compatible-runtimes nodejs22.x nodejs24.x \
--compatible-architectures x86_64 arm64Once deployed set the SOURCE_TOKEN and INGESTING_HOST environment variables on your Lambda to the token and ingesting host from your Better Stack source settings (the ingesting host looks like s123456.lu-trq-1.betterstackdata.com), and add the layer to your Lambda function.
On next invocation your Lambda logs should start appearing in Telemetry -> Live tail.
| Variable | Description | Default |
|---|---|---|
| SOURCE_TOKEN | Better Stack source token | required |
| INGESTING_HOST | Better Stack ingesting host | in.logs.betterstack.com |
| EXTENSION_NAME | Name of the lambda extension | logtail-lambda-extension |
| RECEIVER_ADDRESS | Address of the logs http receiver | sandbox |
| RECEIVER_PORT | Port of the logs http receiver | 4243 |
| MAX_ITEMS | Maximum number of events that can be buffered in memory | 10000 |
| MAX_BYTES | Maximum size in bytes of events that can be buffered | 262144 |
| TIMEOUT_MS | Maximum time (in milliseconds) that a batch is buffered | 1000 |
| AWS_LAMBDA_RUNTIME_API | HTTP base URI to the lambda runtime API | Provided by AWS Lambda environment |
| AWS_LAMBDA_RUNTIME_EXTENSION_API_VERSION | Lambda Extension API version date | 2020-01-01 |
| AWS_LAMBDA_RUNTIME_TELEMETRY_API_VERSION | Telemetry API version date | 2022-07-01 |
SOURCE_TOKEN and INGESTING_HOST fall back to the legacy LOGTAIL_TOKEN and LOGTAIL_HTTP_API_URL (a full URL) variables when they are not set.
Unless explicitly stated otherwise all files in this repository are licensed under the MIT License. See LICENSE for more information.