使用记录 Amazon Keyspaces API 调用 Amazon CloudTrail - Amazon Keyspaces(Apache Cassandra 兼容)
Amazon Web Services 文档中描述的 Amazon Web Services 服务或功能可能因区域而异。要查看适用于中国区域的差异,请参阅 中国的 Amazon Web Services 服务入门 (PDF)

本文属于机器翻译版本。若本译文内容与英语原文存在差异,则一律以英文原文为准。

使用记录 Amazon Keyspaces API 调用 Amazon CloudTrail

Amazon Keyspaces 与一项服务集成,可记录用户 Amazon CloudTrail、角色或 Amazon 服务在 Amazon Keyspaces 中执行的操作。 CloudTrail 将 Amazon Keyspaces 的数据定义语言 (DDL) API 调用和数据操纵语言 (DML) API 调用作为事件捕获。捕获的调用包括来自 Amazon Keyspaces 控制台的调用和对 Amazon Keyspaces API 操作的编程调用。

如果您创建跟踪,则可以允许将 CloudTrail 事件持续传输到亚马逊简单存储服务 (Amazon S3) Service 存储桶,包括亚马逊密钥空间的事件。

如果您未配置跟踪,您仍然可以在 CloudTrail主机上的 “事件历史记录” 中查看最新支持的事件。通过收集的信息 CloudTrail,您可以确定向 Amazon Keyspaces 发出的请求、发出请求的 IP 地址、谁提出了请求、何时提出请求以及其他详细信息。

要了解更多信息 CloudTrail,请参阅Amazon CloudTrail 用户指南

在中配置 Amazon Keyspaces 日志文件条目 CloudTrail

登录的每个 Amazon Keyspaces API 操作都 CloudTrail 包含以 CQL 查询语言表示的请求参数。有关更多信息,请参阅 Amazon Keyspaces(Apache Cassandra 兼容)的 CQL 语言参考

您可以在 Amazon Web Services 账户中查看、搜索和下载最新事件。有关更多信息,请参阅使用事件历史查看 CloudTrail 事件

要持续记录您的事件 Amazon Web Services 账户,包括 Amazon Keyspaces 的事件,请创建跟踪。跟踪允许 CloudTrail 将日志文件传输到 Amazon S3 存储桶。默认情况下,当您在控制台中创建跟踪时,该跟踪将应用于所有 Amazon 区域。跟踪记录 Amazon 分区中所有区域的事件,并将日志文件传送到您指定的 Amazon S3 存储桶。此外,您可以配置其他 Amazon 服务,以进一步分析和处理 CloudTrail 日志中收集的事件数据。

有关更多信息,请参阅《Amazon CloudTrail 用户指南》中的以下主题:

每个事件或日记账条目都包含有关生成请求的人员信息。身份信息有助于您确定以下内容:

  • 请求是使用根证书还是 Amazon Identity and Access Management (IAM) 用户凭证发出。

  • 请求是使用角色还是联合用户的临时安全凭证发出的。

  • 请求是否由其他 Amazon 服务发出。

有关更多信息,请参阅CloudTrail 用户身份元素

中的 Amazon Keyspaces 数据定义语言 (DDL) 信息 CloudTrail

CloudTrail 在您创建账户 Amazon Web Services 账户 时已在您的账户上启用。当 DDL 活动发生在 Amazon Keyspaces 中时,该活动将 Amazon 与其他服务事件一起自动记录在事件历史记录中。 CloudTrail 下表显示了为 Amazon Keyspaces 记录的 DDL 语句。

CloudTrail eventName 语句 CQL 操作 Amazon SDK 操作

CreateKeyspace

DDL

CREATE KEYSPACE

CreateKeyspace

DropKeyspace

DDL

DROP KEYSPACE

DeleteKeyspace

CreateTable

DDL

CREATE TABLE

CreateTable

DropTable

DDL

DROP TABLE

DeleteTable

AlterTable

DDL

ALTER TABLE

UpdateTable, TagResource, UntagResource

Amazon Keyspaces 中的数据操作语言 (DML) 信息 CloudTrail

要启用使用记录 Amazon Keyspaces DML 语句 CloudTrail,您必须先在中启用数据平面 API 活动的日志记录。 CloudTrail您可以选择使用 CloudTrail 控制台记录数据事件类型 Cassandra 表的活动,或者使用命令行界面或 AP Amazon I 操作将该resources.type值设置为使用 C assandra 表来开始在新的或现有跟踪中记录 Amazon Ke AWS::Cassandra::Table yspaces DML 事件。 CloudTrail 有关更多信息,请参阅记录数据事件

下表显示了 CloudTrail 为记录的数据事件Cassandra table

CloudTrail eventName 语句 CQL 操作 Amazon SDK 操作

Select

DML

SELECT

GetKeyspace, GetTable, ListKeyspaces, ListTables ListTagsForResource

Insert

DML

INSERT

没有 Amazon SDK 操作可用

更新

DML

UPDATE

没有 Amazon SDK 操作可用

删除

DML

DELETE

没有 Amazon SDK 操作可用

了解 Amazon Keyspaces 日志文件条目

CloudTrail 日志文件包含一个或多个日志条目。事件代表来自任何来源的单个请求,包括有关请求的操作、操作的日期和时间、请求参数等的信息。 CloudTrail 日志文件不是公共 API 调用的有序堆栈跟踪,因此它们不会按任何特定的顺序出现。

以下示例显示了一个演示CreateKeyspaceDropKeyspaceCreateTable、和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-1", "sourceIPAddress": "10.24.34.01", "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-1:111122223333:/keyspace/mykeyspace/" } ], "eventType": "AwsApiCall", "apiVersion": "3.4.4", "recipientAccountId": "111122223333", "managementEvent": true, "eventCategory": "Management", "tlsDetails": { "tlsVersion": "TLSv1.2", "cipherSuite": "ECDHE-RSA-AES128-GCM-SHA256", "clientProvidedHostHeader": "cassandra.us-east-1.amazonaws.com" }, { "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-1", "sourceIPAddress": "10.24.34.01", "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-1:111122223333:/keyspace/mykeyspace/" } ], "eventType": "AwsApiCall", "apiVersion": "3.4.4", "recipientAccountId": "111122223333", "managementEvent": true, "eventCategory": "Management", "tlsDetails": { "tlsVersion": "TLSv1.2", "cipherSuite": "ECDHE-RSA-AES128-GCM-SHA256", "clientProvidedHostHeader": "cassandra.us-east-1.amazonaws.com" }, { "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-1", "sourceIPAddress": "10.24.34.01", "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-1:111122223333:/keyspace/mykeyspace/table/mytable" } ], "eventType": "AwsApiCall", "apiVersion": "3.4.4", "recipientAccountId": "111122223333", "managementEvent": true, "eventCategory": "Management", "tlsDetails": { "tlsVersion": "TLSv1.2", "cipherSuite": "ECDHE-RSA-AES128-GCM-SHA256", "clientProvidedHostHeader": "cassandra.us-east-1.amazonaws.com" }, { "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-1", "sourceIPAddress": "10.24.34.01", "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-1:111122223333:/keyspace/mykeyspace/table/mytable" } ], "eventType": "AwsApiCall", "apiVersion": "3.4.4", "recipientAccountId": "111122223333", "managementEvent": true, "eventCategory": "Management", "tlsDetails": { "tlsVersion": "TLSv1.2", "cipherSuite": "ECDHE-RSA-AES128-GCM-SHA256", "clientProvidedHostHeader": "cassandra.us-east-1.amazonaws.com" } ] }

以下日志文件显示 SELECT 语句的示例。

{ "eventVersion": "1.09", "userIdentity": { "type": "IAMUser", "principalId": "AKIAIOSFODNN7EXAMPLE", "arn": "arn:aws:iam::111122223333:user/alice", "accountId": "111122223333", "userName": "alice" }, "eventTime": "2023-11-17T10:38:04Z", "eventSource": "cassandra.amazonaws.com", "eventName": "Select", "awsRegion": "us-east-1", "sourceIPAddress": "10.24.34.01", "userAgent": "Cassandra Client/ProtocolV4", "requestParameters": { "keyspaceName": "my_keyspace", "tableName": "my_table", "conditions": [ "pk = **(Redacted)", "ck < 3**(Redacted)0", "region = 't**(Redacted)t'" ], "select": [ "pk", "ck", "region" ], "allowFiltering": true }, "responseElements": null, "requestID": "6d83bbf0-a3d0-4d49-b1d9-e31779a28628", "eventID": "e00552d3-34e9-4092-931a-912c4e08ba17", "readOnly": true, "resources": [ { "accountId": "111122223333", "type": "AWS::Cassandra::Table", "ARN": "arn:aws:cassandra:us-east-1:111122223333:/keyspace/my_keyspace/table/my_table" } ], "eventType": "AwsApiCall", "apiVersion": "3.4.4", "managementEvent": false, "recipientAccountId": "111122223333", "eventCategory": "Data", "tlsDetails": { "tlsVersion": "TLSv1.3", "cipherSuite": "TLS_AES_128_GCM_SHA256", "clientProvidedHostHeader": "cassandra.us-east-1.amazonaws.com" } }

以下日志文件显示 INSERT 语句的示例。

{ "eventVersion": "1.09", "userIdentity": { "type": "IAMUser", "principalId": "AKIAIOSFODNN7EXAMPLE", "arn": "arn:aws:iam::111122223333:user/alice", "accountId": "111122223333", "userName": "alice" }, "eventTime": "2023-12-01T22:11:43Z", "eventSource": "cassandra.amazonaws.com", "eventName": "Insert", "awsRegion": "us-east-1", "sourceIPAddress": "10.24.34.01", "userAgent": "Cassandra Client/ProtocolV4", "requestParameters": { "keyspaceName": "my_keyspace", "tableName": "my_table", "primaryKeys": { "pk": "**(Redacted)", "ck": "1**(Redacted)8" }, "columnNames": [ "pk", "ck", "region" ], "updateParameters": { "TTL": "2**(Redacted)0" } } }, "responseElements": null, "requestID": "edf8af47-2f87-4432-864d-a960ac35e471", "eventID": "81b56a1c-9bdd-4c92-bb8e-92776b5a3bf1", "readOnly": false, "resources": [ { "accountId": "111122223333", "type": "AWS::Cassandra::Table", "ARN": "arn:aws:cassandra:us-east-1:111122223333:/keyspace/my_keyspace/table/my_table" } ], "eventType": "AwsApiCall", "apiVersion": "3.4.4", "managementEvent": false, "recipientAccountId": "111122223333", "eventCategory": "Data", "tlsDetails": { "tlsVersion": "TLSv1.3", "cipherSuite": "TLS_AES_128_GCM_SHA256", "clientProvidedHostHeader": "cassandra.us-east-1.amazonaws.com" } }

以下日志文件显示 UPDATE 语句的示例。

{ "eventVersion": "1.09", "userIdentity": { "type": "IAMUser", "principalId": "AKIAIOSFODNN7EXAMPLE", "arn": "arn:aws:iam::111122223333:user/alice", "accountId": "111122223333", "userName": "alice" }, "eventTime": "2023-12-01T22:11:43Z", "eventSource": "cassandra.amazonaws.com", "eventName": "Update", "awsRegion": "us-east-1", "sourceIPAddress": "10.24.34.01", "userAgent": "Cassandra Client/ProtocolV4", "requestParameters": { "keyspaceName": "my_keyspace", "tableName": "my_table", "primaryKeys": { "pk": "'t**(Redacted)t'", "ck": "'s**(Redacted)g'" }, "assignmentColumnNames": [ "nonkey" ], "conditions": [ "nonkey < 1**(Redacted)7" ] }, "responseElements": null, "requestID": "edf8af47-2f87-4432-864d-a960ac35e471", "eventID": "81b56a1c-9bdd-4c92-bb8e-92776b5a3bf1", "readOnly": false, "resources": [ { "accountId": "111122223333", "type": "AWS::Cassandra::Table", "ARN": "arn:aws:cassandra:us-east-1:111122223333:/keyspace/my_keyspace/table/my_table" } ], "eventType": "AwsApiCall", "apiVersion": "3.4.4", "managementEvent": false, "recipientAccountId": "111122223333", "eventCategory": "Data", "tlsDetails": { "tlsVersion": "TLSv1.3", "cipherSuite": "TLS_AES_128_GCM_SHA256", "clientProvidedHostHeader": "cassandra.us-east-1.amazonaws.com" } }

以下日志文件显示 DELETE 语句的示例。

{ "eventVersion": "1.09", "userIdentity": { "type": "IAMUser", "principalId": "AKIAIOSFODNN7EXAMPLE", "arn": "arn:aws:iam::111122223333:user/alice", "accountId": "111122223333", "userName": "alice", }, "eventTime": "2023-10-23T13:59:05Z", "eventSource": "cassandra.amazonaws.com", "eventName": "Delete", "awsRegion": "us-east-1", "sourceIPAddress": "10.24.34.01", "userAgent": "Cassandra Client/ProtocolV4", "requestParameters": { "keyspaceName": "my_keyspace", "tableName": "my_table", "primaryKeys": { "pk": "**(Redacted)", "ck": "**(Redacted)" }, "conditions": [], "deleteColumnNames": [ "m", "s" ], "updateParameters": {} }, "responseElements": null, "requestID": "3d45e63b-c0c8-48e2-bc64-31afc5b4f49d", "eventID": "499da055-c642-4762-8775-d91757f06512", "readOnly": false, "resources": [ { "accountId": "111122223333", "type": "AWS::Cassandra::Table", "ARN": "arn:aws:cassandra:us-east-1:111122223333:/keyspace/my_keyspace/table/my_table" } ], "eventType": "AwsApiCall", "apiVersion": "3.4.4", "managementEvent": false, "recipientAccountId": "111122223333", "eventCategory": "Data", "tlsDetails": { "tlsVersion": "TLSv1.3", "cipherSuite": "TLS_AES_128_GCM_SHA256", "clientProvidedHostHeader": "cassandra.us-east-1.amazonaws.com" } }