• 沒有找到結果。

Amazon Kinesis Data Streams Service API Reference API Version 2013-12-02

N/A
N/A
Protected

Academic year: 2022

Share "Amazon Kinesis Data Streams Service API Reference API Version 2013-12-02"

Copied!
143
0
0

加載中.... (立即查看全文)

全文

(1)

Amazon Kinesis Data Streams Service

API Reference

API Version 2013-12-02

(2)

Amazon Kinesis Data Streams Service: API Reference

Copyright © Amazon Web Services, Inc. and/or its affiliates. All rights reserved.

Amazon's trademarks and trade dress may not be used in connection with any product or service that is not Amazon's, in any manner that is likely to cause confusion among customers, or in any manner that disparages or discredits Amazon. All other trademarks not owned by Amazon are the property of their respective owners, who may or may not be affiliated with, connected to, or sponsored by Amazon.

(3)

Table of Contents

Welcome ... 1

Actions ... 2

AddTagsToStream ... 3

Request Syntax ... 3

Request Parameters ... 3

Response Elements ... 3

Errors ... 3

Examples ... 4

See Also ... 5

CreateStream ... 6

Request Syntax ... 6

Request Parameters ... 6

Response Elements ... 7

Errors ... 7

Examples ... 8

See Also ... 8

DecreaseStreamRetentionPeriod ... 9

Request Syntax ... 9

Request Parameters ... 9

Response Elements ... 9

Errors ... 9

Examples ... 10

See Also ... 10

DeleteStream ... 12

Request Syntax ... 12

Request Parameters ... 12

Response Elements ... 12

Errors ... 13

Examples ... 13

See Also ... 13

DeregisterStreamConsumer ... 15

Request Syntax ... 15

Request Parameters ... 15

Response Elements ... 16

Errors ... 16

See Also ... 16

DescribeLimits ... 17

Response Syntax ... 17

Response Elements ... 17

Errors ... 17

Examples ... 18

See Also ... 18

DescribeStream ... 19

Request Syntax ... 19

Request Parameters ... 19

Response Syntax ... 20

Response Elements ... 20

Errors ... 21

Examples ... 21

See Also ... 22

DescribeStreamConsumer ... 24

Request Syntax ... 24

Request Parameters ... 24

Response Syntax ... 25

(4)

Response Elements ... 25

Errors ... 25

See Also ... 25

DescribeStreamSummary ... 27

Request Syntax ... 27

Request Parameters ... 27

Response Syntax ... 27

Response Elements ... 28

Errors ... 28

See Also ... 28

DisableEnhancedMonitoring ... 29

Request Syntax ... 29

Request Parameters ... 29

Response Syntax ... 30

Response Elements ... 30

Errors ... 30

Examples ... 31

See Also ... 32

EnableEnhancedMonitoring ... 33

Request Syntax ... 33

Request Parameters ... 33

Response Syntax ... 34

Response Elements ... 34

Errors ... 34

Examples ... 35

See Also ... 36

GetRecords ... 37

Request Syntax ... 37

Request Parameters ... 38

Response Syntax ... 38

Response Elements ... 38

Errors ... 39

Examples ... 40

See Also ... 41

GetShardIterator ... 42

Request Syntax ... 42

Request Parameters ... 42

Response Syntax ... 43

Response Elements ... 44

Errors ... 44

Examples ... 44

See Also ... 45

IncreaseStreamRetentionPeriod ... 46

Request Syntax ... 46

Request Parameters ... 46

Response Elements ... 46

Errors ... 46

Examples ... 47

See Also ... 47

ListShards ... 49

Request Syntax ... 49

Request Parameters ... 49

Response Syntax ... 51

Response Elements ... 51

Errors ... 52

Examples ... 52

See Also ... 53

(5)

ListStreamConsumers ... 55

Request Syntax ... 55

Request Parameters ... 55

Response Syntax ... 56

Response Elements ... 56

Errors ... 57

See Also ... 57

ListStreams ... 59

Request Syntax ... 59

Request Parameters ... 59

Response Syntax ... 59

Response Elements ... 60

Errors ... 60

Examples ... 60

See Also ... 61

ListTagsForStream ... 62

Request Syntax ... 62

Request Parameters ... 62

Response Syntax ... 62

Response Elements ... 63

Errors ... 63

Examples ... 63

See Also ... 64

MergeShards ... 65

Request Syntax ... 65

Request Parameters ... 65

Response Elements ... 66

Errors ... 66

Examples ... 67

See Also ... 67

PutRecord ... 68

Request Syntax ... 68

Request Parameters ... 68

Response Syntax ... 70

Response Elements ... 70

Errors ... 70

Examples ... 71

See Also ... 72

PutRecords ... 73

Request Syntax ... 74

Request Parameters ... 74

Response Syntax ... 74

Response Elements ... 74

Errors ... 75

Examples ... 76

See Also ... 78

RegisterStreamConsumer ... 79

Request Syntax ... 79

Request Parameters ... 79

Response Syntax ... 79

Response Elements ... 80

Errors ... 80

See Also ... 80

RemoveTagsFromStream ... 82

Request Syntax ... 82

Request Parameters ... 82

Response Elements ... 82

(6)

Errors ... 82

Examples ... 83

See Also ... 83

SplitShard ... 85

Request Syntax ... 85

Request Parameters ... 85

Response Elements ... 86

Errors ... 86

Examples ... 87

See Also ... 87

StartStreamEncryption ... 89

Request Syntax ... 89

Request Parameters ... 89

Response Elements ... 90

Errors ... 90

See Also ... 91

StopStreamEncryption ... 92

Request Syntax ... 92

Request Parameters ... 92

Response Elements ... 93

Errors ... 93

See Also ... 93

SubscribeToShard ... 95

Request Syntax ... 95

Request Parameters ... 95

Response Syntax ... 96

Response Elements ... 97

Errors ... 97

See Also ... 97

UpdateShardCount ... 99

Request Syntax ... 99

Request Parameters ... 99

Response Syntax ... 100

Response Elements ... 100

Errors ... 101

Examples ... 101

See Also ... 102

UpdateStreamMode ... 103

Request Syntax ... 103

Request Parameters ... 103

Response Elements ... 103

Errors ... 103

See Also ... 104

Data Types ... 105

ChildShard ... 106

Contents ... 106

See Also ... 106

Consumer ... 107

Contents ... 107

See Also ... 107

ConsumerDescription ... 109

Contents ... 109

See Also ... 110

EnhancedMetrics ... 111

Contents ... 111

See Also ... 111

HashKeyRange ... 112

(7)

Contents ... 112

See Also ... 112

PutRecordsRequestEntry ... 113

Contents ... 113

See Also ... 113

PutRecordsResultEntry ... 114

Contents ... 114

See Also ... 114

Record ... 115

Contents ... 115

See Also ... 116

SequenceNumberRange ... 117

Contents ... 117

See Also ... 117

Shard ... 118

Contents ... 118

See Also ... 118

ShardFilter ... 120

Contents ... 120

See Also ... 120

StartingPosition ... 122

Contents ... 122

See Also ... 122

StreamDescription ... 124

Contents ... 124

See Also ... 126

StreamDescriptionSummary ... 127

Contents ... 127

See Also ... 129

StreamModeDetails ... 130

Contents ... 130

See Also ... 130

SubscribeToShardEvent ... 131

Contents ... 131

See Also ... 131

SubscribeToShardEventStream ... 132

Contents ... 132

See Also ... 133

Tag ... 134

Contents ... 134

See Also ... 134

Common Errors ... 135

(8)

Welcome

Amazon Kinesis Data Streams is a managed service that scales elastically for real-time processing of streaming big data.

This document was last published on March 6, 2022.

(9)

Actions

The following actions are supported:

• AddTagsToStream (p. 3)

• CreateStream (p. 6)

• DecreaseStreamRetentionPeriod (p. 9)

• DeleteStream (p. 12)

• DeregisterStreamConsumer (p. 15)

• DescribeLimits (p. 17)

• DescribeStream (p. 19)

• DescribeStreamConsumer (p. 24)

• DescribeStreamSummary (p. 27)

• DisableEnhancedMonitoring (p. 29)

• EnableEnhancedMonitoring (p. 33)

• GetRecords (p. 37)

• GetShardIterator (p. 42)

• IncreaseStreamRetentionPeriod (p. 46)

• ListShards (p. 49)

• ListStreamConsumers (p. 55)

• ListStreams (p. 59)

• ListTagsForStream (p. 62)

• MergeShards (p. 65)

• PutRecord (p. 68)

• PutRecords (p. 73)

• RegisterStreamConsumer (p. 79)

• RemoveTagsFromStream (p. 82)

• SplitShard (p. 85)

• StartStreamEncryption (p. 89)

• StopStreamEncryption (p. 92)

• SubscribeToShard (p. 95)

• UpdateShardCount (p. 99)

• UpdateStreamMode (p. 103)

(10)

AddTagsToStream

AddTagsToStream

Adds or updates tags for the specified Kinesis data stream. You can assign up to 50 tags to a data stream.

If tags have already been assigned to the stream, AddTagsToStream overwrites any existing tags that correspond to the specified tag keys.

AddTagsToStream (p. 3) has a limit of five transactions per second per account.

Request Syntax

{

"StreamName": "string", "Tags": {

"string" : "string"

}}

Request Parameters

The request accepts the following data in JSON format.

StreamName (p. 3)

The name of the stream.

Type: String

Length Constraints: Minimum length of 1. Maximum length of 128.

Pattern: [a-zA-Z0-9_.-]+

Required: Yes Tags (p. 3)

A set of up to 10 key-value pairs to use to create the tags.

Type: String to string map

Map Entries: Maximum number of 200 items.

Key Length Constraints: Minimum length of 1. Maximum length of 128.

Value Length Constraints: Minimum length of 0. Maximum length of 256.

Required: Yes

Response Elements

If the action is successful, the service sends back an HTTP 200 response with an empty HTTP body.

Errors

For information about the errors that are common to all actions, see Common Errors (p. 135).

(11)

Examples

InvalidArgumentException

A specified parameter exceeds its restrictions, is not supported, or can't be used. For more information, see the returned message.

HTTP Status Code: 400 LimitExceededException

The requested resource exceeds the maximum number allowed, or the number of concurrent stream requests exceeds the maximum number allowed.

HTTP Status Code: 400 ResourceInUseException

The resource is not available for this operation. For successful operation, the resource must be in the ACTIVE state.

HTTP Status Code: 400 ResourceNotFoundException

The requested resource could not be found. The stream might not be specified correctly.

HTTP Status Code: 400

Examples

To add tags to a stream

The following JSON example adds two tags to the specified stream.

Sample Request

POST / HTTP/1.1

Host: kinesis.<region>.<domain>

Content-Length: <PayloadSizeBytes>

User-Agent: <UserAgentString>

Content-Type: application/x-amz-json-1.1 Authorization: <AuthParams>

Connection: Keep-Alive X-Amz-Date: <Date>

X-Amz-Target: Kinesis_20131202.AddTagsToStream { "StreamName": "exampleStreamName",

"Tags": {

"Project" : "myProject", "Environment" : "Production"

}}

Sample Response

HTTP/1.1 200 OK

x-amzn-RequestId: <RequestId>

Content-Type: application/x-amz-json-1.1 Content-Length: <PayloadSizeBytes>

Date: <Date>

(12)

See Also

See Also

For more information about using this API in one of the language-specific AWS SDKs, see the following:

• AWS Command Line Interface

• AWS SDK for .NET

• AWS SDK for C++

• AWS SDK for Go

• AWS SDK for Java V2

• AWS SDK for JavaScript

• AWS SDK for PHP V3

• AWS SDK for Python

• AWS SDK for Ruby V3

(13)

CreateStream

CreateStream

Creates a Kinesis data stream. A stream captures and transports data records that are continuously emitted from different data sources or producers. Scale-out within a stream is explicitly supported by means of shards, which are uniquely identified groups of data records in a stream.

You can create your data stream using either on-demand or provisioned capacity mode. Data streams with an on-demand mode require no capacity planning and automatically scale to handle gigabytes of write and read throughput per minute. With the on-demand mode, Kinesis Data Streams automatically manages the shards in order to provide the necessary throughput. For the data streams with a

provisioned mode, you must specify the number of shards for the data stream. Each shard can support reads up to five transactions per second, up to a maximum data read total of 2 MiB per second. Each shard can support writes up to 1,000 records per second, up to a maximum data write total of 1 MiB per second. If the amount of data input increases or decreases, you can add or remove shards.

The stream name identifies the stream. The name is scoped to the AWS account used by the application.

It is also scoped by AWS Region. That is, two streams in two different accounts can have the same name, and two streams in the same account, but in two different Regions, can have the same name.

CreateStream is an asynchronous operation. Upon receiving a CreateStream request, Kinesis Data Streams immediately returns and sets the stream status to CREATING. After the stream is created, Kinesis Data Streams sets the stream status to ACTIVE. You should perform read and write operations only on an ACTIVE stream.

You receive a LimitExceededException when making a CreateStream request when you try to do one of the following:

• Have more than five streams in the CREATING state at any point in time.

• Create more shards than are authorized for your account.

For the default shard limit for an AWS account, see Amazon Kinesis Data Streams Limits in the Amazon Kinesis Data Streams Developer Guide. To increase this limit, contact AWS Support.

You can use DescribeStreamSummary (p. 27) to check the stream status, which is returned in StreamStatus.

CreateStream (p. 6) has a limit of five transactions per second per account.

Request Syntax

{

"ShardCount": number, "StreamModeDetails": { "StreamMode": "string"

},

"StreamName": "string"

}

Request Parameters

The request accepts the following data in JSON format.

ShardCount (p. 6)

The number of shards that the stream will use. The throughput of the stream is a function of the number of shards; more shards are required for greater provisioned throughput.

(14)

Response Elements

Type: Integer

Valid Range: Minimum value of 1.

Required: No

StreamModeDetails (p. 6)

Indicates the capacity mode of the data stream. Currently, in Kinesis Data Streams, you can choose between an on-demand capacity mode and a provisioned capacity mode for your data streams.

Type: StreamModeDetails (p. 130) object Required: No

StreamName (p. 6)

A name to identify the stream. The stream name is scoped to the AWS account used by the application that creates the stream. It is also scoped by AWS Region. That is, two streams in two different AWS accounts can have the same name. Two streams in the same AWS account but in two different Regions can also have the same name.

Type: String

Length Constraints: Minimum length of 1. Maximum length of 128.

Pattern: [a-zA-Z0-9_.-]+

Required: Yes

Response Elements

If the action is successful, the service sends back an HTTP 200 response with an empty HTTP body.

Errors

For information about the errors that are common to all actions, see Common Errors (p. 135).

InvalidArgumentException

A specified parameter exceeds its restrictions, is not supported, or can't be used. For more information, see the returned message.

HTTP Status Code: 400 LimitExceededException

The requested resource exceeds the maximum number allowed, or the number of concurrent stream requests exceeds the maximum number allowed.

HTTP Status Code: 400 ResourceInUseException

The resource is not available for this operation. For successful operation, the resource must be in the ACTIVE state.

HTTP Status Code: 400

(15)

Examples

Examples

To create a stream

The following JSON example creates a stream with three shards.

Sample Request

POST / HTTP/1.1

Host: kinesis.<region>.<domain>

Content-Length: <PayloadSizeBytes>

User-Agent: <UserAgentString>

Content-Type: application/x-amz-json-1.1 Authorization: <AuthParams>

Connection: Keep-Alive X-Amz-Date: <Date>

X-Amz-Target: Kinesis_20131202.CreateStream {

"StreamName": "exampleStreamName", }

Sample Response

HTTP/1.1 200 OK

x-amzn-RequestId: <RequestId>

Content-Type: application/x-amz-json-1.1 Content-Length: <PayloadSizeBytes>

Date: <Date>

See Also

For more information about using this API in one of the language-specific AWS SDKs, see the following:

• AWS Command Line Interface

• AWS SDK for .NET

• AWS SDK for C++

• AWS SDK for Go

• AWS SDK for Java V2

• AWS SDK for JavaScript

• AWS SDK for PHP V3

• AWS SDK for Python

• AWS SDK for Ruby V3

(16)

DecreaseStreamRetentionPeriod

DecreaseStreamRetentionPeriod

Decreases the Kinesis data stream's retention period, which is the length of time data records are accessible after they are added to the stream. The minimum value of a stream's retention period is 24 hours.

This operation may result in lost data. For example, if the stream's retention period is 48 hours and is decreased to 24 hours, any data already in the stream that is older than 24 hours is inaccessible.

Request Syntax

{ "RetentionPeriodHours": number, "StreamName": "string"

}

Request Parameters

The request accepts the following data in JSON format.

RetentionPeriodHours (p. 9)

The new retention period of the stream, in hours. Must be less than the current retention period.

Type: Integer Required: Yes StreamName (p. 9)

The name of the stream to modify.

Type: String

Length Constraints: Minimum length of 1. Maximum length of 128.

Pattern: [a-zA-Z0-9_.-]+

Required: Yes

Response Elements

If the action is successful, the service sends back an HTTP 200 response with an empty HTTP body.

Errors

For information about the errors that are common to all actions, see Common Errors (p. 135).

InvalidArgumentException

A specified parameter exceeds its restrictions, is not supported, or can't be used. For more information, see the returned message.

HTTP Status Code: 400

(17)

Examples

LimitExceededException

The requested resource exceeds the maximum number allowed, or the number of concurrent stream requests exceeds the maximum number allowed.

HTTP Status Code: 400 ResourceInUseException

The resource is not available for this operation. For successful operation, the resource must be in the ACTIVE state.

HTTP Status Code: 400 ResourceNotFoundException

The requested resource could not be found. The stream might not be specified correctly.

HTTP Status Code: 400

Examples

To decrease stream retention period

The following JSON example decreases a stream's retention period.

Sample Request

POST / HTTP/1.1

Host: kinesis.<region>.<domain>

Content-Length: <PayloadSizeBytes>

User-Agent: <UserAgentString>

Content-Type: application/x-amz-json-1.1 Authorization: <AuthParams>

Connection: Keep-Alive X-Amz-Date: <Date>

X-Amz-Target: Kinesis_20131202.DecreaseStreamRetentionPeriod {

"RetentionPeriodInHours": "24", "StreamName": "examplestream"

}

Sample Response

HTTP/1.1 200 OK

x-amzn-RequestId: <RequestId>

Content-Type: application/x-amz-json-1.1 Content-Length: <PayloadSizeBytes>

Date: <Date>

See Also

For more information about using this API in one of the language-specific AWS SDKs, see the following:

• AWS Command Line Interface

• AWS SDK for .NET

• AWS SDK for C++

(18)

See Also

• AWS SDK for Go

• AWS SDK for Java V2

• AWS SDK for JavaScript

• AWS SDK for PHP V3

• AWS SDK for Python

• AWS SDK for Ruby V3

(19)

DeleteStream

DeleteStream

Deletes a Kinesis data stream and all its shards and data. You must shut down any applications that are operating on the stream before you delete the stream. If an application attempts to operate on a deleted stream, it receives the exception ResourceNotFoundException.

If the stream is in the ACTIVE state, you can delete it. After a DeleteStream request, the specified stream is in the DELETING state until Kinesis Data Streams completes the deletion.

Note: Kinesis Data Streams might continue to accept data read and write operations, such as PutRecord (p. 68), PutRecords (p. 73), and GetRecords (p. 37), on a stream in the DELETING state until the stream deletion is complete.

When you delete a stream, any shards in that stream are also deleted, and any tags are dissociated from the stream.

You can use the DescribeStreamSummary (p. 27) operation to check the state of the stream, which is returned in StreamStatus.

DeleteStream (p. 12) has a limit of five transactions per second per account.

Request Syntax

{ "EnforceConsumerDeletion": boolean, "StreamName": "string"

}

Request Parameters

The request accepts the following data in JSON format.

EnforceConsumerDeletion (p. 12)

If this parameter is unset (null) or if you set it to false, and the stream has registered consumers, the call to DeleteStream fails with a ResourceInUseException.

Type: Boolean Required: No StreamName (p. 12)

The name of the stream to delete.

Type: String

Length Constraints: Minimum length of 1. Maximum length of 128.

Pattern: [a-zA-Z0-9_.-]+

Required: Yes

Response Elements

If the action is successful, the service sends back an HTTP 200 response with an empty HTTP body.

(20)

Errors

Errors

For information about the errors that are common to all actions, see Common Errors (p. 135).

LimitExceededException

The requested resource exceeds the maximum number allowed, or the number of concurrent stream requests exceeds the maximum number allowed.

HTTP Status Code: 400 ResourceInUseException

The resource is not available for this operation. For successful operation, the resource must be in the ACTIVE state.

HTTP Status Code: 400 ResourceNotFoundException

The requested resource could not be found. The stream might not be specified correctly.

HTTP Status Code: 400

Examples

To delete a stream

The following JSON example deletes the specified stream.

Sample Request

POST / HTTP/1.1

Host: kinesis.<region>.<domain>

Content-Length: <PayloadSizeBytes>

User-Agent: <UserAgentString>

Content-Type: application/x-amz-json-1.1 Authorization: <AuthParams>

Connection: Keep-Alive X-Amz-Date: <Date>

X-Amz-Target: Kinesis_20131202.DeleteStream { "StreamName":"exampleStreamName"

}

Sample Response

HTTP/1.1 200 OK

x-amzn-RequestId: <RequestId>

Content-Type: application/x-amz-json-1.1 Content-Length: <PayloadSizeBytes>

Date: <Date>

See Also

For more information about using this API in one of the language-specific AWS SDKs, see the following:

(21)

See Also

• AWS Command Line Interface

• AWS SDK for .NET

• AWS SDK for C++

• AWS SDK for Go

• AWS SDK for Java V2

• AWS SDK for JavaScript

• AWS SDK for PHP V3

• AWS SDK for Python

• AWS SDK for Ruby V3

(22)

DeregisterStreamConsumer

DeregisterStreamConsumer

To deregister a consumer, provide its ARN. Alternatively, you can provide the ARN of the data stream and the name you gave the consumer when you registered it. You may also provide all three parameters, as long as they don't conflict with each other. If you don't know the name or ARN of the consumer that you want to deregister, you can use the ListStreamConsumers (p. 55) operation to get a list of the descriptions of all the consumers that are currently registered with a given data stream. The description of a consumer contains its name and ARN.

This operation has a limit of five transactions per second per stream.

Request Syntax

{

"ConsumerARN": "string", "ConsumerName": "string", "StreamARN": "string"

}

Request Parameters

The request accepts the following data in JSON format.

ConsumerARN (p. 15)

The ARN returned by Kinesis Data Streams when you registered the consumer. If you don't know the ARN of the consumer that you want to deregister, you can use the ListStreamConsumers operation to get a list of the descriptions of all the consumers that are currently registered with a given data stream. The description of a consumer contains its ARN.

Type: String

Length Constraints: Minimum length of 1. Maximum length of 2048.

Pattern: ^(arn):aws.*:kinesis:.*:\d{12}:.*stream\/[a-zA-Z0-9_.-]+\/consumer\/

[a-zA-Z0-9_.-]+:[0-9]+

Required: No ConsumerName (p. 15)

The name that you gave to the consumer.

Type: String

Length Constraints: Minimum length of 1. Maximum length of 128.

Pattern: [a-zA-Z0-9_.-]+

Required: No StreamARN (p. 15)

The ARN of the Kinesis data stream that the consumer is registered with. For more information, see Amazon Resource Names (ARNs) and AWS Service Namespaces.

Type: String

Length Constraints: Minimum length of 1. Maximum length of 2048.

(23)

Response Elements

Pattern: arn:aws.*:kinesis:.*:\d{12}:stream/.+

Required: No

Response Elements

If the action is successful, the service sends back an HTTP 200 response with an empty HTTP body.

Errors

For information about the errors that are common to all actions, see Common Errors (p. 135).

InvalidArgumentException

A specified parameter exceeds its restrictions, is not supported, or can't be used. For more information, see the returned message.

HTTP Status Code: 400 LimitExceededException

The requested resource exceeds the maximum number allowed, or the number of concurrent stream requests exceeds the maximum number allowed.

HTTP Status Code: 400 ResourceNotFoundException

The requested resource could not be found. The stream might not be specified correctly.

HTTP Status Code: 400

See Also

For more information about using this API in one of the language-specific AWS SDKs, see the following:

• AWS Command Line Interface

• AWS SDK for .NET

• AWS SDK for C++

• AWS SDK for Go

• AWS SDK for Java V2

• AWS SDK for JavaScript

• AWS SDK for PHP V3

• AWS SDK for Python

• AWS SDK for Ruby V3

(24)

DescribeLimits

DescribeLimits

Describes the shard limits and usage for the account.

If you update your account limits, the old limits might be returned for a few minutes.

This operation has a limit of one transaction per second per account.

Response Syntax

{ "OnDemandStreamCount": number, "OnDemandStreamCountLimit": number, "OpenShardCount": number,

"ShardLimit": number }

Response Elements

If the action is successful, the service sends back an HTTP 200 response.

The following data is returned in JSON format by the service.

OnDemandStreamCount (p. 17)

Indicates the number of data streams with the on-demand capacity mode.

Type: Integer

Valid Range: Minimum value of 0. Maximum value of 1000000.

OnDemandStreamCountLimit (p. 17)

The maximum number of data streams with the on-demand capacity mode.

Type: Integer

Valid Range: Minimum value of 0. Maximum value of 1000000.

OpenShardCount (p. 17) The number of open shards.

Type: Integer

Valid Range: Minimum value of 0. Maximum value of 1000000.

ShardLimit (p. 17)

The maximum number of shards.

Type: Integer

Valid Range: Minimum value of 0. Maximum value of 1000000.

Errors

For information about the errors that are common to all actions, see Common Errors (p. 135).

(25)

Examples

LimitExceededException

The requested resource exceeds the maximum number allowed, or the number of concurrent stream requests exceeds the maximum number allowed.

HTTP Status Code: 400

Examples

To display the shard limits for the account

The following example displays the shard limits for the account.

Sample Request

POST / HTTP/1.1

Host: kinesis.<region>.<domain>

Content-Length: <PayloadSizeBytes>

User-Agent: <UserAgentString>

Content-Type: application/x-amz-json-1.1 Authorization: <AuthParams>

Connection: Keep-Alive X-Amz-Date: <Date>

X-Amz-Target: Kinesis_20131202.DescribeLimits

Sample Response

HTTP/1.1 200 OK

x-amzn-RequestId: <RequestId>

Content-Type: application/x-amz-json-1.1 Content-Length: <PayloadSizeBytes>

Date: <Date>

{ "OpenShardCount": 20, "ShardLimit": 70 }

See Also

For more information about using this API in one of the language-specific AWS SDKs, see the following:

• AWS Command Line Interface

• AWS SDK for .NET

• AWS SDK for C++

• AWS SDK for Go

• AWS SDK for Java V2

• AWS SDK for JavaScript

• AWS SDK for PHP V3

• AWS SDK for Python

• AWS SDK for Ruby V3

(26)

DescribeStream

DescribeStream

Describes the specified Kinesis data stream.

Note

This API has been revised. It's highly recommended that you use the

DescribeStreamSummary (p. 27) API to get a summarized description of the specified Kinesis data stream and the ListShards (p. 49) API to list the shards in a specified data stream and obtain information about each shard.

The information returned includes the stream name, Amazon Resource Name (ARN), creation time, enhanced metric configuration, and shard map. The shard map is an array of shard objects. For each shard object, there is the hash key and sequence number ranges that the shard spans, and the IDs of any earlier shards that played in a role in creating the shard. Every record ingested in the stream is identified by a sequence number, which is assigned when the record is put into the stream.

You can limit the number of shards returned by each call. For more information, see Retrieving Shards from a Stream in the Amazon Kinesis Data Streams Developer Guide.

There are no guarantees about the chronological order shards returned. To process shards in chronological order, use the ID of the parent shard to track the lineage to the oldest shard.

This operation has a limit of 10 transactions per second per account.

Request Syntax

{ "ExclusiveStartShardId": "string", "Limit": number,

"StreamName": "string"

}

Request Parameters

The request accepts the following data in JSON format.

ExclusiveStartShardId (p. 19)

The shard ID of the shard to start with.

Specify this parameter to indicate that you want to describe the stream starting with the shard whose ID immediately follows ExclusiveStartShardId.

If you don't specify this parameter, the default behavior for DescribeStream is to describe the stream starting with the first shard in the stream.

Type: String

Pattern: shardId-[0-9]{12}

Required: No Limit (p. 19)

The maximum number of shards to return in a single call. The default value is 100. If you specify a value greater than 100, at most 100 results are returned.

(27)

Response Syntax

Type: Integer

Valid Range: Minimum value of 1. Maximum value of 10000.

Required: No StreamName (p. 19)

The name of the stream to describe.

Type: String

Length Constraints: Minimum length of 1. Maximum length of 128.

Pattern: [a-zA-Z0-9_.-]+

Required: Yes

Response Syntax

{

"StreamDescription": { "EncryptionType": "string", "EnhancedMonitoring": [ {

"ShardLevelMetrics": [ "string" ] }

],

"HasMoreShards": boolean, "KeyId": "string",

"RetentionPeriodHours": number, "Shards": [

{

"AdjacentParentShardId": "string", "HashKeyRange": {

"EndingHashKey": "string", "StartingHashKey": "string"

},

"ParentShardId": "string", "SequenceNumberRange": {

"EndingSequenceNumber": "string", "StartingSequenceNumber": "string"

},

"ShardId": "string"

} ],

"StreamARN": "string",

"StreamCreationTimestamp": number, "StreamModeDetails": {

"StreamMode": "string"

},

"StreamName": "string", "StreamStatus": "string"

}}

Response Elements

If the action is successful, the service sends back an HTTP 200 response.

The following data is returned in JSON format by the service.

(28)

Errors

StreamDescription (p. 20)

The current status of the stream, the stream Amazon Resource Name (ARN), an array of shard objects that comprise the stream, and whether there are more shards available.

Type: StreamDescription (p. 124) object

Errors

For information about the errors that are common to all actions, see Common Errors (p. 135).

LimitExceededException

The requested resource exceeds the maximum number allowed, or the number of concurrent stream requests exceeds the maximum number allowed.

HTTP Status Code: 400 ResourceNotFoundException

The requested resource could not be found. The stream might not be specified correctly.

HTTP Status Code: 400

Examples

To get information about a stream

The following JSON example describes the specified stream.

Sample Request

POST / HTTP/1.1

Host: kinesis.<region>.<domain>

Content-Length: <PayloadSizeBytes>

User-Agent: <UserAgentString>

Content-Type: application/x-amz-json-1.1 Authorization: <AuthParams>

Connection: Keep-Alive X-Amz-Date: <Date>

X-Amz-Target: Kinesis_20131202.DescribeStream { "StreamName":"exampleStreamName"

}

Sample Response

HTTP/1.1 200 OK

x-amzn-RequestId: <RequestId>

Content-Type: application/x-amz-json-1.1 Content-Length: <PayloadSizeBytes>

Date: <Date>

{ "StreamDescription": { "EnhancedMonitoring":[

{

"ShardLevelMetrics":[

(29)

See Also

"IncomingBytes", "OutgoingRecords"

] } ],

"HasMoreShards": false, "RetentionPeriodHours": 24,

"StreamCreationTimestamp": 1.468346745E9, "Shards": [

{

"HashKeyRange": {

"EndingHashKey": "113427455640312821154458202477256070484", "StartingHashKey": "0"

},

"SequenceNumberRange": {

"EndingSequenceNumber": "21269319989741826081360214168359141376", "StartingSequenceNumber": "21267647932558653966460912964485513216"

},

"ShardId": "shardId-000000000000"

}, {

"HashKeyRange": {

"EndingHashKey": "226854911280625642308916404954512140969", "StartingHashKey": "113427455640312821154458202477256070485"

},

"SequenceNumberRange": {

"StartingSequenceNumber": "21267647932558653966460912964485513217"

},

"ShardId": "shardId-000000000001"

}, {

"HashKeyRange": {

"EndingHashKey": "340282366920938463463374607431768211455", "StartingHashKey": "226854911280625642308916404954512140970"

},

"SequenceNumberRange": {

"StartingSequenceNumber": "21267647932558653966460912964485513218"

},

"ShardId": "shardId-000000000002"

} ],

"StreamARN": "arn:aws:kinesis:us-east-1:111122223333:exampleStreamName", "StreamName": "exampleStreamName",

"StreamStatus": "ACTIVE"

}}

See Also

For more information about using this API in one of the language-specific AWS SDKs, see the following:

• AWS Command Line Interface

• AWS SDK for .NET

• AWS SDK for C++

• AWS SDK for Go

• AWS SDK for Java V2

• AWS SDK for JavaScript

• AWS SDK for PHP V3

• AWS SDK for Python

• AWS SDK for Ruby V3

(30)

See Also

(31)

DescribeStreamConsumer

DescribeStreamConsumer

To get the description of a registered consumer, provide the ARN of the consumer. Alternatively, you can provide the ARN of the data stream and the name you gave the consumer when you registered it. You may also provide all three parameters, as long as they don't conflict with each other. If you don't know the name or ARN of the consumer that you want to describe, you can use the ListStreamConsumers (p. 55) operation to get a list of the descriptions of all the consumers that are currently registered with a given data stream.

This operation has a limit of 20 transactions per second per stream.

Request Syntax

{ "ConsumerARN": "string", "ConsumerName": "string", "StreamARN": "string"

}

Request Parameters

The request accepts the following data in JSON format.

ConsumerARN (p. 24)

The ARN returned by Kinesis Data Streams when you registered the consumer.

Type: String

Length Constraints: Minimum length of 1. Maximum length of 2048.

Pattern: ^(arn):aws.*:kinesis:.*:\d{12}:.*stream\/[a-zA-Z0-9_.-]+\/consumer\/

[a-zA-Z0-9_.-]+:[0-9]+

Required: No ConsumerName (p. 24)

The name that you gave to the consumer.

Type: String

Length Constraints: Minimum length of 1. Maximum length of 128.

Pattern: [a-zA-Z0-9_.-]+

Required: No StreamARN (p. 24)

The ARN of the Kinesis data stream that the consumer is registered with. For more information, see Amazon Resource Names (ARNs) and AWS Service Namespaces.

Type: String

Length Constraints: Minimum length of 1. Maximum length of 2048.

Pattern: arn:aws.*:kinesis:.*:\d{12}:stream/.+

(32)

Response Syntax

Required: No

Response Syntax

{

"ConsumerDescription": { "ConsumerARN": "string",

"ConsumerCreationTimestamp": number, "ConsumerName": "string",

"ConsumerStatus": "string", "StreamARN": "string"

}}

Response Elements

If the action is successful, the service sends back an HTTP 200 response.

The following data is returned in JSON format by the service.

ConsumerDescription (p. 25)

An object that represents the details of the consumer.

Type: ConsumerDescription (p. 109) object

Errors

For information about the errors that are common to all actions, see Common Errors (p. 135).

InvalidArgumentException

A specified parameter exceeds its restrictions, is not supported, or can't be used. For more information, see the returned message.

HTTP Status Code: 400 LimitExceededException

The requested resource exceeds the maximum number allowed, or the number of concurrent stream requests exceeds the maximum number allowed.

HTTP Status Code: 400 ResourceNotFoundException

The requested resource could not be found. The stream might not be specified correctly.

HTTP Status Code: 400

See Also

For more information about using this API in one of the language-specific AWS SDKs, see the following:

• AWS Command Line Interface

• AWS SDK for .NET

(33)

See Also

• AWS SDK for C++

• AWS SDK for Go

• AWS SDK for Java V2

• AWS SDK for JavaScript

• AWS SDK for PHP V3

• AWS SDK for Python

• AWS SDK for Ruby V3

(34)

DescribeStreamSummary

DescribeStreamSummary

Provides a summarized description of the specified Kinesis data stream without the shard list.

The information returned includes the stream name, Amazon Resource Name (ARN), status, record retention period, approximate creation time, monitoring, encryption details, and open shard count.

DescribeStreamSummary (p. 27) has a limit of 20 transactions per second per account.

Request Syntax

{ "StreamName": "string"

}

Request Parameters

The request accepts the following data in JSON format.

StreamName (p. 27)

The name of the stream to describe.

Type: String

Length Constraints: Minimum length of 1. Maximum length of 128.

Pattern: [a-zA-Z0-9_.-]+

Required: Yes

Response Syntax

{

"StreamDescriptionSummary": { "ConsumerCount": number, "EncryptionType": "string", "EnhancedMonitoring": [ {

"ShardLevelMetrics": [ "string" ] }

],

"KeyId": "string",

"OpenShardCount": number, "RetentionPeriodHours": number, "StreamARN": "string",

"StreamCreationTimestamp": number, "StreamModeDetails": {

"StreamMode": "string"

},

"StreamName": "string", "StreamStatus": "string"

}}

(35)

Response Elements

Response Elements

If the action is successful, the service sends back an HTTP 200 response.

The following data is returned in JSON format by the service.

StreamDescriptionSummary (p. 27)

A StreamDescriptionSummary (p. 127) containing information about the stream.

Type: StreamDescriptionSummary (p. 127) object

Errors

For information about the errors that are common to all actions, see Common Errors (p. 135).

LimitExceededException

The requested resource exceeds the maximum number allowed, or the number of concurrent stream requests exceeds the maximum number allowed.

HTTP Status Code: 400 ResourceNotFoundException

The requested resource could not be found. The stream might not be specified correctly.

HTTP Status Code: 400

See Also

For more information about using this API in one of the language-specific AWS SDKs, see the following:

• AWS Command Line Interface

• AWS SDK for .NET

• AWS SDK for C++

• AWS SDK for Go

• AWS SDK for Java V2

• AWS SDK for JavaScript

• AWS SDK for PHP V3

• AWS SDK for Python

• AWS SDK for Ruby V3

(36)

DisableEnhancedMonitoring

DisableEnhancedMonitoring

Disables enhanced monitoring.

Request Syntax

{ "ShardLevelMetrics": [ "string" ], "StreamName": "string"

}

Request Parameters

The request accepts the following data in JSON format.

ShardLevelMetrics (p. 29)

List of shard-level metrics to disable.

The following are the valid shard-level metrics. The value "ALL" disables every metric.

• IncomingBytes

• IncomingRecords

• OutgoingBytes

• OutgoingRecords

• WriteProvisionedThroughputExceeded

• ReadProvisionedThroughputExceeded

• IteratorAgeMilliseconds

• ALL

For more information, see Monitoring the Amazon Kinesis Data Streams Service with Amazon CloudWatch in the Amazon Kinesis Data Streams Developer Guide.

Type: Array of strings

Array Members: Minimum number of 1 item. Maximum number of 7 items.

Valid Values: IncomingBytes | IncomingRecords | OutgoingBytes | OutgoingRecords

| WriteProvisionedThroughputExceeded | ReadProvisionedThroughputExceeded | IteratorAgeMilliseconds | ALL

Required: Yes StreamName (p. 29)

The name of the Kinesis data stream for which to disable enhanced monitoring.

Type: String

Length Constraints: Minimum length of 1. Maximum length of 128.

Pattern: [a-zA-Z0-9_.-]+

Required: Yes

(37)

Response Syntax

Response Syntax

{ "CurrentShardLevelMetrics": [ "string" ], "DesiredShardLevelMetrics": [ "string" ], "StreamName": "string"

}

Response Elements

If the action is successful, the service sends back an HTTP 200 response.

The following data is returned in JSON format by the service.

CurrentShardLevelMetrics (p. 30)

Represents the current state of the metrics that are in the enhanced state before the operation.

Type: Array of strings

Array Members: Minimum number of 1 item. Maximum number of 7 items.

Valid Values: IncomingBytes | IncomingRecords | OutgoingBytes | OutgoingRecords

| WriteProvisionedThroughputExceeded | ReadProvisionedThroughputExceeded | IteratorAgeMilliseconds | ALL

DesiredShardLevelMetrics (p. 30)

Represents the list of all the metrics that would be in the enhanced state after the operation.

Type: Array of strings

Array Members: Minimum number of 1 item. Maximum number of 7 items.

Valid Values: IncomingBytes | IncomingRecords | OutgoingBytes | OutgoingRecords

| WriteProvisionedThroughputExceeded | ReadProvisionedThroughputExceeded | IteratorAgeMilliseconds | ALL

StreamName (p. 30)

The name of the Kinesis data stream.

Type: String

Length Constraints: Minimum length of 1. Maximum length of 128.

Pattern: [a-zA-Z0-9_.-]+

Errors

For information about the errors that are common to all actions, see Common Errors (p. 135).

InvalidArgumentException

A specified parameter exceeds its restrictions, is not supported, or can't be used. For more information, see the returned message.

HTTP Status Code: 400

(38)

Examples

LimitExceededException

The requested resource exceeds the maximum number allowed, or the number of concurrent stream requests exceeds the maximum number allowed.

HTTP Status Code: 400 ResourceInUseException

The resource is not available for this operation. For successful operation, the resource must be in the ACTIVE state.

HTTP Status Code: 400 ResourceNotFoundException

The requested resource could not be found. The stream might not be specified correctly.

HTTP Status Code: 400

Examples

To disable enhanced monitoring

The following JSON example disables enhanced monitoring for IncomingBytes and OutgoingRecords shard level metrics.

Sample Request

POST / HTTP/1.1

Host: kinesis.<region>.<domain>

Content-Length: <PayloadSizeBytes>

User-Agent: <UserAgentString>

Content-Type: application/x-amz-json-1.1 Authorization: <AuthParams>

Connection: Keep-Alive X-Amz-Date: <Date>

X-Amz-Target: Kinesis_20131202.DisableEnhancedMonitoring { "ShardLevelMetrics": [

"IncomingBytes", "OutgoingRecords"

],

"StreamName": "exampleStreamName"

}

Sample Response

HTTP/1.1 200 OK

x-amzn-RequestId: <RequestId>

Content-Type: application/x-amz-json-1.1 Content-Length: <PayloadSizeBytes>

Date: <Date>

{ "StreamName": "exampleStreamName", "CurrentShardLevelMetrics": [ "IncomingBytes",

"OutgoingRecords"

],

"DesiredShardLevelMetrics": []

}

(39)

See Also

See Also

For more information about using this API in one of the language-specific AWS SDKs, see the following:

• AWS Command Line Interface

• AWS SDK for .NET

• AWS SDK for C++

• AWS SDK for Go

• AWS SDK for Java V2

• AWS SDK for JavaScript

• AWS SDK for PHP V3

• AWS SDK for Python

• AWS SDK for Ruby V3

(40)

EnableEnhancedMonitoring

EnableEnhancedMonitoring

Enables enhanced Kinesis data stream monitoring for shard-level metrics.

Request Syntax

{ "ShardLevelMetrics": [ "string" ], "StreamName": "string"

}

Request Parameters

The request accepts the following data in JSON format.

ShardLevelMetrics (p. 33)

List of shard-level metrics to enable.

The following are the valid shard-level metrics. The value "ALL" enables every metric.

• IncomingBytes

• IncomingRecords

• OutgoingBytes

• OutgoingRecords

• WriteProvisionedThroughputExceeded

• ReadProvisionedThroughputExceeded

• IteratorAgeMilliseconds

• ALL

For more information, see Monitoring the Amazon Kinesis Data Streams Service with Amazon CloudWatch in the Amazon Kinesis Data Streams Developer Guide.

Type: Array of strings

Array Members: Minimum number of 1 item. Maximum number of 7 items.

Valid Values: IncomingBytes | IncomingRecords | OutgoingBytes | OutgoingRecords

| WriteProvisionedThroughputExceeded | ReadProvisionedThroughputExceeded | IteratorAgeMilliseconds | ALL

Required: Yes StreamName (p. 33)

The name of the stream for which to enable enhanced monitoring.

Type: String

Length Constraints: Minimum length of 1. Maximum length of 128.

Pattern: [a-zA-Z0-9_.-]+

Required: Yes

(41)

Response Syntax

Response Syntax

{ "CurrentShardLevelMetrics": [ "string" ], "DesiredShardLevelMetrics": [ "string" ], "StreamName": "string"

}

Response Elements

If the action is successful, the service sends back an HTTP 200 response.

The following data is returned in JSON format by the service.

CurrentShardLevelMetrics (p. 34)

Represents the current state of the metrics that are in the enhanced state before the operation.

Type: Array of strings

Array Members: Minimum number of 1 item. Maximum number of 7 items.

Valid Values: IncomingBytes | IncomingRecords | OutgoingBytes | OutgoingRecords

| WriteProvisionedThroughputExceeded | ReadProvisionedThroughputExceeded | IteratorAgeMilliseconds | ALL

DesiredShardLevelMetrics (p. 34)

Represents the list of all the metrics that would be in the enhanced state after the operation.

Type: Array of strings

Array Members: Minimum number of 1 item. Maximum number of 7 items.

Valid Values: IncomingBytes | IncomingRecords | OutgoingBytes | OutgoingRecords

| WriteProvisionedThroughputExceeded | ReadProvisionedThroughputExceeded | IteratorAgeMilliseconds | ALL

StreamName (p. 34)

The name of the Kinesis data stream.

Type: String

Length Constraints: Minimum length of 1. Maximum length of 128.

Pattern: [a-zA-Z0-9_.-]+

Errors

For information about the errors that are common to all actions, see Common Errors (p. 135).

InvalidArgumentException

A specified parameter exceeds its restrictions, is not supported, or can't be used. For more information, see the returned message.

HTTP Status Code: 400

(42)

Examples

LimitExceededException

The requested resource exceeds the maximum number allowed, or the number of concurrent stream requests exceeds the maximum number allowed.

HTTP Status Code: 400 ResourceInUseException

The resource is not available for this operation. For successful operation, the resource must be in the ACTIVE state.

HTTP Status Code: 400 ResourceNotFoundException

The requested resource could not be found. The stream might not be specified correctly.

HTTP Status Code: 400

Examples

To enable enhanced monitoring

The following JSON example enables enhanced monitoring for IncomingBytes and OutgoingRecords shard level metrics.

Sample Request

POST / HTTP/1.1

Host: kinesis.<region>.<domain>

Content-Length: <PayloadSizeBytes>

User-Agent: <UserAgentString>

Content-Type: application/x-amz-json-1.1 Authorization: <AuthParams>

Connection: Keep-Alive X-Amz-Date: <Date>

X-Amz-Target: Kinesis_20131202.EnableEnhancedMonitoring { "ShardLevelMetrics": [

"IncomingBytes", "OutgoingRecords"

],

"StreamName": "exampleStreamName"

}

Sample Response

HTTP/1.1 200 OK

x-amzn-RequestId: <RequestId>

Content-Type: application/x-amz-json-1.1 Content-Length: <PayloadSizeBytes>

Date: <Date>

{ "StreamName": "exampleStreamName", "CurrentShardLevelMetrics": [], "DesiredShardLevelMetrics": [ "IncomingBytes",

"OutgoingRecords"

] }

(43)

See Also

See Also

For more information about using this API in one of the language-specific AWS SDKs, see the following:

• AWS Command Line Interface

• AWS SDK for .NET

• AWS SDK for C++

• AWS SDK for Go

• AWS SDK for Java V2

• AWS SDK for JavaScript

• AWS SDK for PHP V3

• AWS SDK for Python

• AWS SDK for Ruby V3

(44)

GetRecords

GetRecords

Gets data records from a Kinesis data stream's shard.

Specify a shard iterator using the ShardIterator parameter. The shard iterator specifies the position in the shard from which you want to start reading data records sequentially. If there are no records available in the portion of the shard that the iterator points to, GetRecords (p. 37) returns an empty list. It might take multiple calls to get to a portion of the shard that contains records.

You can scale by provisioning multiple shards per stream while considering service limits (for more information, see Amazon Kinesis Data Streams Limits in the Amazon Kinesis Data Streams Developer Guide). Your application should have one thread per shard, each reading continuously from its stream.

To read from a stream continually, call GetRecords (p. 37) in a loop. Use GetShardIterator (p. 42) to get the shard iterator to specify in the first GetRecords (p. 37) call. GetRecords (p. 37) returns a new shard iterator in NextShardIterator. Specify the shard iterator returned in NextShardIterator in subsequent calls to GetRecords (p. 37). If the shard has been closed, the shard iterator can't return more data and GetRecords (p. 37) returns null in NextShardIterator.

You can terminate the loop when the shard is closed, or when the shard iterator reaches the record with the sequence number or other attribute that marks it as the last record to process.

Each data record can be up to 1 MiB in size, and each shard can read up to 2 MiB per second. You can ensure that your calls don't exceed the maximum supported size or throughput by using the Limit parameter to specify the maximum number of records that GetRecords (p. 37) can return. Consider your average record size when determining this limit. The maximum number of records that can be returned per call is 10,000.

The size of the data returned by GetRecords (p. 37) varies depending on the utilization of the shard. It is recommended that consumer applications retrieve records via the GetRecords command using the 5 TPS limit to remain caught up. Retrieving records less frequently can lead to consumer applications falling behind. The maximum size of data that GetRecords (p. 37) can return is 10 MiB. If a call returns this amount of data, subsequent calls made within the next 5 seconds throw ProvisionedThroughputExceededException. If there is insufficient provisioned throughput on the stream, subsequent calls made within the next 1 second throw ProvisionedThroughputExceededException. GetRecords (p. 37) doesn't return any data when it throws an exception. For this reason, we recommend that you wait 1 second between calls to GetRecords (p. 37). However, it's possible that the application will get exceptions for longer than 1 second.

To detect whether the application is falling behind in processing, you can use the

MillisBehindLatest response attribute. You can also monitor the stream using CloudWatch metrics and other mechanisms (see Monitoring in the Amazon Kinesis Data Streams Developer Guide).

Each Amazon Kinesis record includes a value, ApproximateArrivalTimestamp, that is set when a stream successfully receives and stores a record. This is commonly referred to as a server-side time stamp, whereas a client-side time stamp is set when a data producer creates or sends the record to a stream (a data producer is any data source putting data records into a stream, for example with PutRecords (p. 73)). The time stamp has millisecond precision. There are no guarantees about the time stamp accuracy, or that the time stamp is always increasing. For example, records in a shard or across a stream might have time stamps that are out of order.

This operation has a limit of five transactions per second per shard.

Request Syntax

{

"Limit": number,

"ShardIterator": "string"

(45)

Request Parameters

}

Request Parameters

The request accepts the following data in JSON format.

Limit (p. 37)

The maximum number of records to return. Specify a value of up to 10,000. If you specify a value that is greater than 10,000, GetRecords (p. 37) throws InvalidArgumentException. The default value is 10,000.

Type: Integer

Valid Range: Minimum value of 1. Maximum value of 10000.

Required: No ShardIterator (p. 37)

The position in the shard from which you want to start sequentially reading data records. A shard iterator specifies this position using the sequence number of a data record in the shard.

Type: String

Length Constraints: Minimum length of 1. Maximum length of 512.

Required: Yes

Response Syntax

{ "ChildShards": [ {

"HashKeyRange": {

"EndingHashKey": "string", "StartingHashKey": "string"

},

"ParentShards": [ "string" ], "ShardId": "string"

} ],

"MillisBehindLatest": number, "NextShardIterator": "string", "Records": [

{

"ApproximateArrivalTimestamp": number, "Data": blob,

"EncryptionType": "string", "PartitionKey": "string", "SequenceNumber": "string"

} ] }

Response Elements

If the action is successful, the service sends back an HTTP 200 response.

(46)

Errors

The following data is returned in JSON format by the service.

ChildShards (p. 38)

The list of the current shard's child shards, returned in the GetRecords API's response only when the end of the current shard is reached.

Type: Array of ChildShard (p. 106) objects MillisBehindLatest (p. 38)

The number of milliseconds the GetRecords (p. 37) response is from the tip of the stream, indicating how far behind current time the consumer is. A value of zero indicates that record processing is caught up, and there are no new records to process at this moment.

Type: Long

Valid Range: Minimum value of 0.

NextShardIterator (p. 38)

The next position in the shard from which to start sequentially reading data records. If set to null, the shard has been closed and the requested iterator does not return any more data.

Type: String

Length Constraints: Minimum length of 1. Maximum length of 512.

Records (p. 38)

The data records retrieved from the shard.

Type: Array of Record (p. 115) objects

Errors

For information about the errors that are common to all actions, see Common Errors (p. 135).

ExpiredIteratorException

The provided iterator exceeds the maximum age allowed.

HTTP Status Code: 400 InvalidArgumentException

A specified parameter exceeds its restrictions, is not supported, or can't be used. For more information, see the returned message.

HTTP Status Code: 400 KMSAccessDeniedException

The ciphertext references a key that doesn't exist or that you don't have access to.

HTTP Status Code: 400 KMSDisabledException

The request was rejected because the specified customer master key (CMK) isn't enabled.

HTTP Status Code: 400

(47)

Examples

KMSInvalidStateException

The request was rejected because the state of the specified resource isn't valid for this request.

For more information, see How Key State Affects Use of a Customer Master Key in the AWS Key Management Service Developer Guide.

HTTP Status Code: 400 KMSNotFoundException

The request was rejected because the specified entity or resource can't be found.

HTTP Status Code: 400 KMSOptInRequired

The AWS access key ID needs a subscription for the service.

HTTP Status Code: 400 KMSThrottlingException

The request was denied due to request throttling. For more information about throttling, see Limits in the AWS Key Management Service Developer Guide.

HTTP Status Code: 400

ProvisionedThroughputExceededException

The request rate for the stream is too high, or the requested data is too large for the available throughput. Reduce the frequency or size of your requests. For more information, see Streams Limits in the Amazon Kinesis Data Streams Developer Guide, and Error Retries and Exponential Backoff in AWS in the AWS General Reference.

HTTP Status Code: 400 ResourceNotFoundException

The requested resource could not be found. The stream might not be specified correctly.

HTTP Status Code: 400

Examples

To get data from the shards in a stream

The following JSON example gets data from the shards in a stream.

Sample Request

POST / HTTP/1.1

Host: kinesis.<region>.<domain>

Content-Length: <PayloadSizeBytes>

User-Agent: <UserAgentString>

Content-Type: application/x-amz-json-1.1 Authorization: <AuthParams>

Connection: Keep-Alive X-Amz-Date: <Date>

X-Amz-Target: Kinesis_20131202.GetRecords {

"ShardIterator": "AAAAAAAAAAETYyAYzd665+8e0X7JTsASDM/

Hr2rSwc0X2qz93iuA3udrjTH+ikQvpQk/1ZcMMLzRdAesqwBGPnsthzU0/CBlM/

(48)

See Also

U8/8oEqGwX3pKw0XyeDNRAAZyXBo3MqkQtCpXhr942BRTjvWKhFz7OmCb2Ncfr8Tl2cBktooi6kJhr +djN5WYkB38Rr3akRgCl9qaU4dY=",

"Limit": 25 }

Sample Response

HTTP/1.1 200 OK

x-amzn-RequestId: <RequestId>

Content-Type: application/x-amz-json-1.1 Content-Length: <PayloadSizeBytes>

Date: <Date>

{ "MillisBehindLatest": 2100,

"NextShardIterator": "AAAAAAAAAAHsW8zCWf9164uy8Epue6WS3w6wmj4a4USt+CNvMd6uXQ

+HL5vAJMznqqC0DLKsIjuoiTi1BpT6nW0LN2M2D56zM5H8anHm30Gbri9ua+qaGgj+3XTyvbhpERfrezgLHbPB/

rIcVpykJbaSj5tmcXYRmFnqZBEyHwtZYFmh6hvWVFkIwLuMZLMrpWhG5r5hzkE=", "Records": [

{

"Data": "XzxkYXRhPl8w",

"PartitionKey": "partitionKey",

"ApproximateArrivalTimestamp": 1.441215410867E9,

"SequenceNumber": "21269319989652663814458848515492872193"

} ] }

See Also

For more information about using this API in one of the language-specific AWS SDKs, see the following:

• AWS Command Line Interface

• AWS SDK for .NET

• AWS SDK for C++

• AWS SDK for Go

• AWS SDK for Java V2

• AWS SDK for JavaScript

• AWS SDK for PHP V3

• AWS SDK for Python

• AWS SDK for Ruby V3

(49)

GetShardIterator

GetShardIterator

Gets an Amazon Kinesis shard iterator. A shard iterator expires 5 minutes after it is returned to the requester.

A shard iterator specifies the shard position from which to start reading data records sequentially. The position is specified using the sequence number of a data record in a shard. A sequence number is the identifier associated with every record ingested in the stream, and is assigned when a record is put into the stream. Each stream has one or more shards.

You must specify the shard iterator type. For example, you can set the ShardIteratorType parameter to read exactly from the position denoted by a specific sequence number by using the AT_SEQUENCE_NUMBER shard iterator type. Alternatively, the parameter can read right after the sequence number by using the AFTER_SEQUENCE_NUMBER shard iterator type, using sequence numbers returned by earlier calls to PutRecord (p. 68), PutRecords (p. 73), GetRecords (p. 37), or DescribeStream (p. 19). In the request, you can specify the shard iterator type AT_TIMESTAMP to read records from an arbitrary point in time, TRIM_HORIZON to cause ShardIterator to point to the last untrimmed record in the shard in the system (the oldest data record in the shard), or LATEST so that you always read the most recent data in the shard.

When you read repeatedly from a stream, use a GetShardIterator (p. 42) request to get the first shard iterator for use in your first GetRecords (p. 37) request and for subsequent reads use the shard iterator returned by the GetRecords (p. 37) request in NextShardIterator. A new shard iterator is returned by every GetRecords (p. 37) request in NextShardIterator, which you use in the ShardIterator parameter of the next GetRecords (p. 37) request.

If a GetShardIterator (p. 42) request is made too often, you receive a

ProvisionedThroughputExceededException. For more information about throughput limits, see GetRecords (p. 37), and Streams Limits in the Amazon Kinesis Data Streams Developer Guide.

If the shard is closed, GetShardIterator (p. 42) returns a valid iterator for the last sequence number of the shard. A shard can be closed as a result of using SplitShard (p. 85) or MergeShards (p. 65).

GetShardIterator (p. 42) has a limit of five transactions per second per account per open shard.

Request Syntax

{

"ShardId": "string",

"ShardIteratorType": "string", "StartingSequenceNumber": "string", "StreamName": "string",

"Timestamp": number }

Request Parameters

The request accepts the following data in JSON format.

ShardId (p. 42)

The shard ID of the Kinesis Data Streams shard to get the iterator for.

Type: String

Pattern: shardId-[0-9]{12}

Required: Yes

參考文獻

相關文件

Microphone and 600 ohm line conduits shall be mechanically and electrically connected to receptacle boxes and electrically grounded to the audio system ground point.. Lines in

In 2007, results of the analysis carried out by the Laboratory of the Civic and Municipal Affairs Bureau indicated that the quality of the potable water of the distribution

– The The readLine readLine method is the same method used to read method is the same method used to read  from the keyboard, but in this case it would read from a 

Reading Task 6: Genre Structure and Language Features. • Now let’s look at how language features (e.g. sentence patterns) are connected to the structure

Map the elements of elective modules to the Compulsory Part of the school- based Senior Secondary EL curriculum?. Adjust the breadth and depth of learning

Teachers may consider the school’s aims and conditions or even the language environment to select the most appropriate approach according to students’ need and ability; or develop

Courtesy: Ned Wright’s Cosmology Page Burles, Nolette &amp; Turner, 1999?. Total Mass Density

中國春秋時期 (The period of Spring and Autumn in China) (770-476BC).. I am from the state of Lu in the Zhou dynasty. I am an official and over 60 years old. Her name is Yan