本文属于机器翻译版本。若本译文内容与英语原文存在差异,则一律以英文原文为准。
使用 Amazon Keyspaces API 调用Amazon CloudTrail
Amazon Keyspaces 与Amazon CloudTrail集成,后者是在 Amazon Keyspaces 中提供用户、角色或Amazon服务所采取操作的记录的服务。 CloudTrail 将亚马逊Keyspaces 的数据定义语言 (DDL) API 调用捕获为事件。捕获的调用包括来自 Amazon Keyspaces 控制台的调用和对 Amazon Keyspaces API 操作的代码调用。
如果您创建了跟踪记录,则可以将 CloudTrail 事件持续传送到某个 Amazon Simple Simple Storage Service (Amazon S3) 存储桶(包括 Amazon Keyspaces 事件)。
如果您不配置跟踪,则仍可在 CloudTrail 控制台的 Event history (事件历史记录) 中查看最新事件。使用收集的信息 CloudTrail,您可以确定向 Amazon Keyspaces 发出了什么请求、发出请求的 IP 地址、何人发出的请求、请求的发出时间以及其他详细信息。
要了解更多信息 CloudTrail,请参阅Amazon CloudTrail用户指南。
中的亚马逊Keyspaces 信息 CloudTrail
CloudTrail 在您创建Amazon Web Services 账户时,将在该账户上启用。当 Amazon Kedl 活动在 Amazon Keyspaces 中时,该活动将记录在 CloudTrail 事件中,并与其它Amazon服务事件一同保存在事件历史记录中。下表显示了为亚马逊Keyspaces 记录的 DDL 语句。请注意,数据操作语言 (DML) 语句未登录 CloudTrail。
CloudTrail eventName |
Statement | CQL 行动 | AmazonSDK 操作 |
---|---|---|---|
CreateTable |
DDL |
|
|
CreateKeyspace |
DDL |
|
|
DropKeyspace |
DDL |
|
|
DropTable |
DDL |
|
|
AlterTable |
DDL |
|
|
没有 CloudTrail 活动 |
DML |
|
|
登录的每个操作都 CloudTrail 包含始终以 CQL 查询语言表示的请求参数。
您可以在 Amazon Web Services 账户 中查看、搜索和下载最新事件。有关更多信息,请参阅使用事件历史记录查看 CloudTrail 事件。
要持续记录 Amazon KeyspacAmazon Web Services 账户 es 的事件(包括 Amazon Keyspaces 的事件),请创建跟踪。通过跟踪,可以 CloudTrail 将日志文件 Amazon S3 存储桶。预设情况下,在控制台中创建跟踪时,此跟踪应用于所有 Amazon 区域。此跟踪记录在 Amazon 分区中记录所有区域中的事件,并将日志文件传送至您指定的 Simple Storage Service(Amazon S3)桶。此外,您可以配置其他Amazon服务,进一步分析在 CloudTrail 日志中收集的事件数据并采取行动。
有关更多信息,请参阅 Amazon CloudTrail 用户指南 中的以下主题:
每个事件或日志条目都包含有关生成请求的人员信息。身份信息可帮助您确定以下内容:
-
请求是使用根用户凭证还是 Amazon Identity and Access Management (IAM) 用户凭证发出的
-
请求是使用角色还是联合身份用户的临时安全凭证发出的
-
请求是否由其它 Amazon 服务发出
有关更多信息,请参阅 CloudTrail userIdentity 元素。
了解 Amazon Keyspaces 日志文件条目
跟踪是一种配置,可用于将事件作为日志文件传送到您指定的 Amazon S3 存储桶。 CloudTrail 日志文件,包含一个或多个区域条目。一个事件表示来自任何源的一个请求,包括有关所请求的操作、操作的日期和时间、请求参数等方面的信息。 CloudTrail 日志文件,不是公有 API 调用的有序堆栈跟踪,因此它们不会按任何特定顺序显示。
以下示例显示了一个演示CreateKeyspace
、DropKeyspace
CreateTable
、和DropTable
操作 CloudTrail 的日志条目:
{ "Records": [ { "eventVersion": "1.05", "userIdentity": { "type": "AssumedRole", "principalId": "AKIAIOSFODNN7EXAMPLE:alice", "arn": "arn:aws:sts::111122223333:assumed-role/users/alice", "accountId": "111122223333", "sessionContext": { "sessionIssuer": { "type": "Role", "principalId": "AKIAIOSFODNN7EXAMPLE", "arn": "arn:aws:iam::111122223333:role/Admin", "accountId": "111122223333", "userName": "Admin" }, "webIdFederationData": {}, "attributes": { "mfaAuthenticated": "false", "creationDate": "2020-01-15T18:47:56Z" } } }, "eventTime": "2020-01-15T18:53:04Z", "eventSource": "cassandra.amazonaws.com", "eventName": "CreateKeyspace", "awsRegion": "us-east-2", "sourceIPAddress": "52.95.24.72", "userAgent": "Cassandra Client/ProtocolV4", "requestParameters": { "rawQuery": "\n\tCREATE KEYSPACE \"mykeyspace\"\n\tWITH\n\t\tREPLICATION = {'class': 'SingleRegionStrategy'}\n\t\t", "keyspaceName": "mykeyspace" }, "responseElements": null, "requestID": "bfa3e75d-bf4d-4fc0-be5e-89d15850eb41", "eventID": "d25beae8-f611-4229-877a-921557a07bb9", "readOnly": false, "resources": [ { "accountId": "111122223333", "type": "AWS::Cassandra::Keyspace", "ARN": "arn:aws:cassandra:us-east-2:111122223333:/keyspace/mykeyspace/" } ], "eventType": "AwsApiCall", "apiVersion": "3.4.4", "recipientAccountId": "111122223333" }, { "eventVersion": "1.05", "userIdentity": { "type": "AssumedRole", "principalId": "AKIAIOSFODNN7EXAMPLE:alice", "arn": "arn:aws:sts::111122223333:assumed-role/users/alice", "accountId": "111122223333", "sessionContext": { "sessionIssuer": { "type": "Role", "principalId": "AKIAIOSFODNN7EXAMPLE", "arn": "arn:aws:iam::111122223333:role/Admin", "accountId": "111122223333", "userName": "Admin" }, "webIdFederationData": {}, "attributes": { "mfaAuthenticated": "false", "creationDate": "2020-01-15T18:47:56Z" } } }, "eventTime": "2020-01-15T19:28:39Z", "eventSource": "cassandra.amazonaws.com", "eventName": "DropKeyspace", "awsRegion": "us-east-2", "sourceIPAddress": "52.95.24.73", "userAgent": "Cassandra Client/ProtocolV4", "requestParameters": { "rawQuery": "DROP KEYSPACE \"mykeyspace\"", "keyspaceName": "mykeyspace" }, "responseElements": null, "requestID": "66f3d86a-56ae-4c29-b46f-abcd489ed86b", "eventID": "e5aebeac-e1dd-41e3-a515-84fe6aaabd7b", "readOnly": false, "resources": [ { "accountId": "111122223333", "type": "AWS::Cassandra::Keyspace", "ARN": "arn:aws:cassandra:us-east-2:111122223333:/keyspace/mykeyspace/" } ], "eventType": "AwsApiCall", "apiVersion": "3.4.4", "recipientAccountId": "111122223333" }, { "eventVersion": "1.05", "userIdentity": { "type": "AssumedRole", "principalId": "AKIAIOSFODNN7EXAMPLE:alice", "arn": "arn:aws:sts::111122223333:assumed-role/users/alice", "accountId": "111122223333", "sessionContext": { "sessionIssuer": { "type": "Role", "principalId": "AKIAIOSFODNN7EXAMPLE", "arn": "arn:aws:iam::111122223333:role/Admin", "accountId": "111122223333", "userName": "Admin" }, "webIdFederationData": {}, "attributes": { "mfaAuthenticated": "false", "creationDate": "2020-01-15T18:47:56Z" } } }, "eventTime": "2020-01-15T18:55:24Z", "eventSource": "cassandra.amazonaws.com", "eventName": "CreateTable", "awsRegion": "us-east-2", "sourceIPAddress": "52.95.24.72", "userAgent": "Cassandra Client/ProtocolV4", "requestParameters": { "rawQuery": "\n\tCREATE TABLE \"mykeyspace\".\"mytable\"(\n\t\t\"ID\" int,\n\t\t\"username\" text,\n\t\t\"email\" text,\n\t\t\"post_type\" text,\n\t\tPRIMARY KEY((\"ID\", \"username\", \"email\")))", "keyspaceName": "mykeyspace", "tableName": "mytable" }, "responseElements": null, "requestID": "5f845963-70ea-4988-8a7a-2e66d061aacb", "eventID": "fe0dbd2b-7b34-4675-a30c-740f9d8d73f9", "readOnly": false, "resources": [ { "accountId": "111122223333", "type": "AWS::Cassandra::Table", "ARN": "arn:aws:cassandra:us-east-2:111122223333:/keyspace/mykeyspace/table/mytable" } ], "eventType": "AwsApiCall", "apiVersion": "3.4.4", "recipientAccountId": "111122223333" }, { "eventVersion": "1.05", "userIdentity": { "type": "AssumedRole", "principalId": "AKIAIOSFODNN7EXAMPLE:alice", "arn": "arn:aws:sts::111122223333:assumed-role/users/alice", "accountId": "111122223333", "sessionContext": { "sessionIssuer": { "type": "Role", "principalId": "AKIAIOSFODNN7EXAMPLE", "arn": "arn:aws:iam::111122223333:role/Admin", "accountId": "111122223333", "userName": "Admin" }, "webIdFederationData": {}, "attributes": { "mfaAuthenticated": "false", "creationDate": "2020-01-15T18:47:56Z" } } }, "eventTime": "2020-01-15T19:27:59Z", "eventSource": "cassandra.amazonaws.com", "eventName": "DropTable", "awsRegion": "us-east-2", "sourceIPAddress": "52.95.24.66", "userAgent": "Cassandra Client/ProtocolV4", "requestParameters": { "rawQuery": "DROP TABLE \"mykeyspace\".\"mytable\"", "keyspaceName": "mykeyspace", "tableName": "mytable" }, "responseElements": null, "requestID": "025501b0-3582-437e-9d18-8939e9ef262f", "eventID": "1a5cbedc-4e38-4889-8475-3eab98de0ffd", "readOnly": false, "resources": [ { "accountId": "111122223333", "type": "AWS::Cassandra::Table", "ARN": "arn:aws:cassandra:us-east-2:111122223333:/keyspace/mykeyspace/table/mytable" } ], "eventType": "AwsApiCall", "apiVersion": "3.4.4", "recipientAccountId": "111122223333" } ] }