Amazon Kinesis Data Streams
开发人员指南
AWS 文档中描述的 AWS 服务或功能可能因区域而异。要查看适用于中国区域的差异,请参阅 Amazon AWS 入门

使用 AWS CloudTrail 记录 Amazon Kinesis Data Streams API 调用

Amazon Kinesis Data Streams 与 AWS CloudTrail, 集成在一起,这将捕获由 Kinesis Data Streams 或代表它发出的 API 调用,并将日志文件传送到您指定的 Amazon S3 存储桶。这些 API 调用可通过使用 Kinesis Data Streams 控制台间接发出,也可以通过使用 Kinesis Data Streams API 直接发出。通过使用 CloudTrail 收集的信息,您可以确定向 Kinesis Data Streams 发出了什么请求、发出请求的源 IP 地址、何人发出的请求以及发出请求的时间等。要了解有关 CloudTrail 的更多信息,包括如何对其进行配置和启用,请参阅 AWS CloudTrail User Guide

Kinesis Data Streams 和 CloudTrail

默认情况下,CloudTrail 日志记录处于启用状态。将在日志文件中跟踪对 Kinesis Data Streams 操作进行的调用。Kinesis Data Streams 的记录将与为 CloudTrail 日志记录启用的任何其他 AWS 服务中的记录一起写入日志文件中。CloudTrail 基于指定的时间段和文件大小来确定何时创建新文件并向其写入内容。

支持以下操作:

每个日志条目都包含有关生成请求的人员的信息。例如,如果已发出创建流的请求 (CreateStream),则发出该请求的人员或服务的用户身份会被记录下来。用户身份信息有助于确定发出的请求是否具有根或 IAM 用户证书,是否具有角色或联合用户临时安全证书,或者是否由其他 AWS 服务发出。有关更多信息,请参阅 AWS CloudTrail User Guide 中的 userIdentity 元素

日志文件可以在存储桶中存储任意长时间,不过您也可以定义 Amazon S3 生命周期规则以自动存档或删除日志文件。默认情况下,将使用 Amazon S3 服务器端加密 (SSE) 对日志文件进行加密。

您还可以将多个 AWS 区域和多个 AWS 账户中的 Kinesis Data Streams 日志文件聚合到单个 Amazon S3 存储桶中。有关信息,请参阅 AWS CloudTrail User Guide 中的将 CloudTrail 日志文件聚合到单个 Amazon S3 存储桶中

如果您需要针对日志文件传输快速采取措施,可让 CloudTrail 在传输新的日志文件时发布 SNS 通知。有关信息,请参阅 AWS CloudTrail User Guide 中的配置 Amazon SNS 通知

Kinesis Data Streams 的日志文件条目

CloudTrail 日志文件可包含一个或多个日志条目,每个条目由多个 JSON 格式的事件组成。一个日志条目表示来自任何源的一个请求,包括有关所请求的操作、所有参数以及操作的日期和时间等信息。日志条目不一定具有任何特定顺序。也就是说,这不是 API 调用的有序堆栈跟踪。

以下是示例 CloudTrail 日志条目。

{ "Records": [ { "eventVersion": "1.01", "userIdentity": { "type": "IAMUser", "principalId": "EX_PRINCIPAL_ID", "arn": "arn:aws:iam::012345678910:user/Alice", "accountId": "012345678910", "accessKeyId": "EXAMPLE_KEY_ID", "userName": "Alice" }, "eventTime": "2014-04-19T00:16:31Z", "eventSource": "kinesis.amazonaws.com", "eventName": "CreateStream", "awsRegion": "us-east-1", "sourceIPAddress": "127.0.0.1", "userAgent": "aws-sdk-java/unknown-version Linux/x.xx", "requestParameters": { "shardCount": 1, "streamName": "GoodStream" }, "responseElements": null, "requestID": "db6c59f8-c757-11e3-bc3b-57923b443c1c", "eventID": "b7acfcd0-6ca9-4ee1-a3d7-c4e8d420d99b" }, { "eventVersion": "1.01", "userIdentity": { "type": "IAMUser", "principalId": "EX_PRINCIPAL_ID", "arn": "arn:aws:iam::012345678910:user/Alice", "accountId": "012345678910", "accessKeyId": "EXAMPLE_KEY_ID", "userName": "Alice" }, "eventTime": "2014-04-19T00:17:06Z", "eventSource": "kinesis.amazonaws.com", "eventName": "DescribeStream", "awsRegion": "us-east-1", "sourceIPAddress": "127.0.0.1", "userAgent": "aws-sdk-java/unknown-version Linux/x.xx", "requestParameters": { "streamName": "GoodStream" }, "responseElements": null, "requestID": "f0944d86-c757-11e3-b4ae-25654b1d3136", "eventID": "0b2f1396-88af-4561-b16f-398f8eaea596" }, { "eventVersion": "1.01", "userIdentity": { "type": "IAMUser", "principalId": "EX_PRINCIPAL_ID", "arn": "arn:aws:iam::012345678910:user/Alice", "accountId": "012345678910", "accessKeyId": "EXAMPLE_KEY_ID", "userName": "Alice" }, "eventTime": "2014-04-19T00:15:02Z", "eventSource": "kinesis.amazonaws.com", "eventName": "ListStreams", "awsRegion": "us-east-1", "sourceIPAddress": "127.0.0.1", "userAgent": "aws-sdk-java/unknown-version Linux/x.xx", "requestParameters": { "limit": 10 }, "responseElements": null, "requestID": "a68541ca-c757-11e3-901b-cbcfe5b3677a", "eventID": "22a5fb8f-4e61-4bee-a8ad-3b72046b4c4d" }, { "eventVersion": "1.01", "userIdentity": { "type": "IAMUser", "principalId": "EX_PRINCIPAL_ID", "arn": "arn:aws:iam::012345678910:user/Alice", "accountId": "012345678910", "accessKeyId": "EXAMPLE_KEY_ID", "userName": "Alice" }, "eventTime": "2014-04-19T00:17:07Z", "eventSource": "kinesis.amazonaws.com", "eventName": "DeleteStream", "awsRegion": "us-east-1", "sourceIPAddress": "127.0.0.1", "userAgent": "aws-sdk-java/unknown-version Linux/x.xx", "requestParameters": { "streamName": "GoodStream" }, "responseElements": null, "requestID": "f10cd97c-c757-11e3-901b-cbcfe5b3677a", "eventID": "607e7217-311a-4a08-a904-ec02944596dd" }, { "eventVersion": "1.01", "userIdentity": { "type": "IAMUser", "principalId": "EX_PRINCIPAL_ID", "arn": "arn:aws:iam::012345678910:user/Alice", "accountId": "012345678910", "accessKeyId": "EXAMPLE_KEY_ID", "userName": "Alice" }, "eventTime": "2014-04-19T00:15:03Z", "eventSource": "kinesis.amazonaws.com", "eventName": "SplitShard", "awsRegion": "us-east-1", "sourceIPAddress": "127.0.0.1", "userAgent": "aws-sdk-java/unknown-version Linux/x.xx", "requestParameters": { "shardToSplit": "shardId-000000000000", "streamName": "GoodStream", "newStartingHashKey": "11111111" }, "responseElements": null, "requestID": "a6e6e9cd-c757-11e3-901b-cbcfe5b3677a", "eventID": "dcd2126f-c8d2-4186-b32a-192dd48d7e33" }, { "eventVersion": "1.01", "userIdentity": { "type": "IAMUser", "principalId": "EX_PRINCIPAL_ID", "arn": "arn:aws:iam::012345678910:user/Alice", "accountId": "012345678910", "accessKeyId": "EXAMPLE_KEY_ID", "userName": "Alice" }, "eventTime": "2014-04-19T00:16:56Z", "eventSource": "kinesis.amazonaws.com", "eventName": "MergeShards", "awsRegion": "us-east-1", "sourceIPAddress": "127.0.0.1", "userAgent": "aws-sdk-java/unknown-version Linux/x.xx", "requestParameters": { "streamName": "GoodStream", "adjacentShardToMerge": "shardId-000000000002", "shardToMerge": "shardId-000000000001" }, "responseElements": null, "requestID": "e9f9c8eb-c757-11e3-bf1d-6948db3cd570", "eventID": "77cf0d06-ce90-42da-9576-71986fec411f" } ] }