記錄 Amazon Keyspaces API 調用 AWS CloudTrail - Amazon Keyspaces (適用於 Apache Cassandra)

本文為英文版的機器翻譯版本,如內容有任何歧義或不一致之處,概以英文版為準。

記錄 Amazon Keyspaces API 調用 AWS CloudTrail

Amazon Keyspaces 與服務整合在一起 AWS CloudTrail,該服務可提供 Amazon 密 Keyspaces 中使用者、角色或 AWS 服務所採取的動作記錄。 CloudTrail 將 Amazon Keyspaces 的資料定義語言 (DDL) API 呼叫和資料操縱語言 (DML) API 呼叫擷取為事件。擷取的呼叫包括來自 Amazon Keyspaces 主控台的呼叫,以及對 Amazon Keyspaces API 作業的程式設計呼叫。

如果您建立追蹤,您可以啟用持續交付 CloudTrail 事件到 Amazon Simple Storage Service (Amazon S3) 儲存貯體,包括 Amazon Keyspaces 的事件。

如果您未設定追蹤,您仍然可以在 [事件歷程記錄] 中檢視 CloudTrail主控台上最近支援的事件。使用收集的資訊 CloudTrail,您可以判斷向 Amazon Keyspaces 發出的請求、提出請求的 IP 地址、提出請求的人員、提出請求的時間以及其他詳細資訊。

若要進一步了解 CloudTrail,請參閱使AWS CloudTrail 用者指南

在中配置 Amazon Keyspaces 日誌文件條目 CloudTrail

登入的每個 Amazon Keyspaces API 動作都 CloudTrail 包含以 CQL 查詢語言表示的請求參數。如需更多資訊,請參閱CQL Amazon Keyspaces 的語言參考 (適用於 Apache Cassandra)

您可以檢視、搜尋和下載 AWS 帳戶的最新事件。如需詳細資訊,請參閱使用 CloudTrail 事件歷程記錄檢視事件

對於您的事件的持續記錄 AWS 帳戶,包括 Amazon Keyspaces 的事件,請創建一個跟踪。追蹤可 CloudTrail 將日誌檔交付到 Amazon S3 儲存貯體。根據預設,當您在主控台中建立追蹤時,追蹤會套用至所有 AWS 區域。追蹤記錄來自 AWS 分區中所有區域的事件,並將日誌檔傳送到您指定的 Amazon S3 儲存貯體。此外,您還可以設定其他 AWS 服務,以進一步分析 CloudTrail 記錄中收集的事件資料並採取行動。

如需詳細資訊,請參閱 AWS CloudTrail 使用者指南中的以下主題:

每一筆事件或日誌專案都會包含產生請求者的資訊。身分資訊可協助您判斷下列事項:

  • 要求是使用根使用者登入資料還是 AWS Identity and Access Management (IAM) 使用者登入資料提出。

  • 提出該請求時,是否使用了特定角色或聯合身分使用者的暫時安全憑證。

  • 請求是否由其他 AWS 服務提出。

如需詳細資訊,請參閱CloudTrail 使 userIdentity 元素

Amazon Keyspaces 數據定義語言(DDL)信息 CloudTrail

CloudTrail 在您創建帳戶 AWS 帳戶 時啟用。當在 Amazon Keyspaces 中發生 DDL 活動時,該活動會與事件歷史記錄中的其他 AWS 服務 CloudTrail 事件一起自動記錄為事件。下表顯示了針對 Amazon Keyspaces 記錄的 DDL 語句。

CloudTrail eventName 陳述式 定制列表動作 AWS 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 表的活動,或將resources.type值設定為使用 AWS CLI 或 API 操作,以在新的或現有的追蹤中開始記錄 Amazon Keyspaces DML 事件。AWS::Cassandra::Table CloudTrail 如需詳細資訊,請參閱記錄資料事件

下表顯示的是由記錄的資料事 CloudTrail 件Cassandra table

CloudTrail eventName 陳述式 定制列表動作 AWS SDK 動作

Select

DML

SELECT

GetKeyspace, GetTable, ListKeyspaces, ListTables ListTagsForResource

Insert

DML

INSERT

沒有可用的 AWS SDK 動作

更新

DML

UPDATE

沒有可用的 AWS SDK 動作

Delete

DML

DELETE

沒有可用的 AWS SDK 動作

了解 Amazon Keyspaces 日誌文件條目

CloudTrail 記錄檔包含一或多個記錄項目。事件代表來自任何來源的單一請求,包括有關請求的操作,動作的日期和時間,請求參數等信息。 CloudTrail 日誌文件不是公共 API 調用的有序堆棧跟踪,因此它們不會以任何特定順序顯示。

下列範例顯示示範CreateKeyspaceDropKeyspaceCreateTableDropTable動作的 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" } }