Timestream Write client

This page contains examples with the Timestream Write client. See the client introduction for a more detailed description how to use a client. You may also want to consider the authentication documentation to understand the many ways you can authenticate with AWS.

The Timestream Write package could be installed with Composer.

composer require async-aws/timestream-write

A new client object may be instantiated by:

use AsyncAws\Timestream Write\Timestream WriteClient; $timestream Write = new Timestream WriteClient();

The authentication parameters is read from the environment by default. You can also specify a AWS access id and secret:

use AsyncAws\Timestream Write\Timestream WriteClient; $timestream Write = new Timestream WriteClient([ 'accessKeyId' => 'my_access_key', 'accessKeySecret' => 'my_access_secret', 'region' => 'eu-central-1', ]);

For all available options, see the configuration reference.


Write records

use AsyncAws\TimestreamWrite\Enum\MeasureValueType; use AsyncAws\TimestreamWrite\Input\WriteRecordsResponse; use AsyncAws\TimestreamWrite\TimestreamWriteClient; use AsyncAws\TimestreamWrite\ValueObject\Dimension; use AsyncAws\TimestreamWrite\ValueObject\Record; $timestreamWrite = new TimestreamWriteClient(); $timestreamWrite->writeRecords(new WriteRecordsRequest([ 'DatabaseName' => 'db', 'TableName' => 'tbl', 'CommonAttributes' => new Record([ 'Dimensions' => [ new Dimension(['Name' => 'region', 'Value' => 'us-east-1']), ], ]), 'Records' => [ new Record([ 'MeasureName' => 'cpu_utilization', 'MeasureValue' => '13.5', 'MeasureValueType' => MeasureValueType::DOUBLE, 'Time' => 12345678, ]), new Record([ 'MeasureName' => 'memory_utilization', 'MeasureValue' => '40', 'MeasureValueType' => MeasureValueType::BIGINT, 'Time' => 12345678, ]), ], ]));

The source code to this page is found on GitHub.