📢 Registration + agenda now live
Explore the latest Grafana Cloud and AI solutions, learn tips & tricks from demos and hands-on workshops, and get actionable advice to advance your observability strategy. Register now and get 50% off - limited tickets available (while they last!).
KinesisClient.putRecords(streamName, records) puts multiple records into a Kinesis stream.
Parameters
Parameter
Type
Description
streamName
string
The name of the Kinesis stream to put records into.
records
Array
An array of records to put into the stream.
Records
Each record in the records array should be an object with the following properties:
Property
Type
Description
data
string
The data payload of the record.
partitionKey
string
The partition key for the record.
explicitHashKey
string
Optional. The explicit hash key for the record.
Returns
Type
Description
Promise<Object>
A Promise that fulfills with the put records response.
Returns object
Property
Type
Description
failedRecordCount
number
The number of records that failed to be put.
records
Array
An array of record results.
Record result object
Property
Type
Description
sequenceNumber
string
The sequence number of the record (if successful).
shardId
string
The shard ID where the record was placed (if successful).
errorCode
string
The error code (if the record failed).
errorMessage
string
The error message (if the record failed).
Example
JavaScript
import{
AWSConfig,
KinesisClient,}from'https://jslib.k6.io/aws/0.14.0/kinesis.js';const awsConfig =newAWSConfig({region: __ENV.AWS_REGION,accessKeyId: __ENV.AWS_ACCESS_KEY_ID,secretAccessKey: __ENV.AWS_SECRET_ACCESS_KEY,});const kinesis =newKinesisClient(awsConfig);exportdefaultasyncfunction(){const streamName ='my-test-stream';// Create records to put into the streamconst records =[{data:JSON.stringify({message:'Hello from k6!',timestamp: Date.now(),userId:'user123',}),partitionKey:'user123',},{data:JSON.stringify({message:'Another message',timestamp: Date.now(),userId:'user456',}),partitionKey:'user456',},{data:JSON.stringify({message:'Load test data',timestamp: Date.now(),userId:'user789',}),partitionKey:'user789',explicitHashKey:'123456789012345678901234567890123456789',},];// Put records into the streamconst result =await kinesis.putRecords(streamName, records);
console.log('Put records result:');
console.log('Failed record count:', result.failedRecordCount);// Check individual record results
result.records.forEach((record, index)=>{if(record.errorCode){
console.log(`Record ${index} failed: ${record.errorCode} - ${record.errorMessage}`);}else{
console.log(`Record ${index} succeeded: sequence=${record.sequenceNumber}, shard=${record.shardId}`);}});}