xk6-output-timestream
Output k6 results to AWS Timestream so that you can run a performant, low-cost load test.
Why?
If you're here you've probably chosen to use k6 already and you're probably interested in using an AWS serverless service. These give you the benefits of:
- Performance at scale
- Low cost
- Great Developer experience
For more information see the alternatives
Usage
This output is written as an extension to K6 using xk6 extensions - this is experimental. You'll need to build this into K6 - see the custom build instructions.
Configuration
For all configuration specific to this extension see the Config struct
in config.go.
The key bits of config you'll need to setup are the following environment variables
K6_TIMESTREAM_DATABASE_NAME
K6_TIMESTREAM_TABLE_NAME
There is a sample command in the test-integration
target in the Makefile.
You'll also need to setup your AWS credentials - see the guide on how to do this.
The dimensions (see timestream concepts) are taken from any K6 tags that have non-empty values.
If you do not have any tags setup you will see the error At least one dimension is required for a record.
logged from timestream. More information can be found in the K6 documentation or an example of setting up tags can be found in the integration test script.
Development
I use VSCode for development so this will be the best supported editor. However, you should be able to use other IDEs. If you are using another IDE:
- The Dockerfile
dev
target shows all the tools you need for a dev environment (e.g. For linting).
- There are suggested tools you can also use.
VSCode
The preferred way to develop using VSCode is to use the dev container feature. This will mean you have all the tools required and suggested for development.
If you do want to use different tools (e.g. you don't like the shell setup), create .devcontainer/tools.override.sh
and base it off .devcontainer/tools.default.sh.
If you don't want to use dev containers, you'll need to make sure you install the tools from the Dockerfile and the packages in suggested tools that are needed for the VSCode extensions.
Where to start for development
output.go contains the logic for converting from K6 metric samples to AWS Timestream records and then saving those records.
There are targets for different development tasks in the Makefile.