使用記錄 CloudTrail - Amazon Redshift

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

使用記錄 CloudTrail

使用 AWS CloudTrail 記錄呼叫

Amazon Redshift,數據共享,Amazon Redshift 無服務器,Amazon Redshift 數據 API 和查詢編輯器 v2 都與. AWS CloudTrail CloudTrail 這是一項服務,可提供 Amazon Redshift 中使用者、角色或AWS服務所採取的動作記錄。 CloudTrail以事件形式擷取 Amazon Redshift 的所有 API 呼叫。擷取的呼叫包括從 Redshift 主控台進行的呼叫,以及針對 Redshift 操作的程式碼呼叫。

如果您建立 CloudTrail 追蹤,您可以持續將 CloudTrail 事件傳遞到 Amazon S3 儲存貯體,包括 Redshift 的事件。如果您未設定追蹤,您仍然可以在 [事件歷程記錄] 中檢視 CloudTrail 主控台中最近的事件。使用收集的信息 CloudTrail,您可以確定某些事情。這些事情包括向 Redshift 提出的請求、提出請求的 IP 地址、提出請求的人員、提出請求的時間,以及其他詳細資訊。

您可以在 Amazon Redshift 資料庫稽核記錄之外 CloudTrail 獨立使用,也可以除了使用。

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

使用中的資訊 CloudTrail

CloudTrail 當您建立AWS帳戶時,會在您的帳戶中開啟。當活動發生時,該活動會與事件歷史記錄中的其他AWS服務 CloudTrail 事件一起記錄在事件中。您可以檢視、搜尋和下載 AWS 帳戶的最新事件。如需詳細資訊,請參閱AWS CloudTrail使用指南中的檢視具有 CloudTrail 事件歷程記錄的事件。

如需AWS帳戶中持續記錄事件 (包括 Redshift 的事件),請建立追蹤。 CloudTrail 使用追蹤將日誌檔傳送到 Amazon S3 儲存貯體。根據預設,當您在主控台建立線索時,線索會套用到所有 AWS 區域。該追蹤會記錄來自 AWS 分割區中所有區域的事件,並將日誌檔案交付到您指定的 Amazon S3 儲存貯體。此外,您還可以設定其他AWS服務,以進一步分析 CloudTrail 記錄中收集的事件資料並採取行動。如需詳細資訊,請參閱《AWS CloudTrail 使用者指南》 中的下列主題:

所有 Amazon Redshift、Amazon Redshift 無伺服器、資料 API、資料共用和查詢編輯器 v2 動作均由記錄。 CloudTrail例如,呼叫AuthorizeDatashareCreateNamespaceExecuteStatement、和CreateConnection動作會在 CloudTrail 記錄檔中產生項目。

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

  • 該請求是否使用根或使用者憑證提出。

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

  • 該請求是否由另一項 AWS 服務提出。

若要取得更多資訊,請參閱AWS CloudTrail使用者指南中的使用者 CloudTrail userIdentity 元素

了解日誌檔案項目

追蹤是一種組態,可讓事件以日誌檔的形式傳遞到您指定的 Amazon S3 儲存貯體。 CloudTrail 記錄檔包含一或多個記錄項目。一個事件為任何來源提出的單一請求,並包含請求動作、請求的日期和時間、請求參數等資訊。 CloudTrail 日誌文件不是公共 API 調用的有序堆棧跟踪,因此它們不會以任何特定順序顯示。

Amazon Redshift 資料共用範例

下列範例顯示說明AuthorizeDataShare作業的 CloudTrail 記錄項目。

{ "eventVersion": "1.08", "userIdentity": { "type": "AssumedRole", "principalId": "AKIAIOSFODNN7EXAMPLE:janedoe", "arn": "arn:aws:sts::111122223333:user/janedoe", "accountId": "111122223333", "accessKeyId": "AKIAI44QH8DHBEXAMPLE", "sessionContext": { "sessionIssuer": { "type": "Role", "principalId": "AKIAIOSFODNN7EXAMPLE:janedoe", "arn": "arn:aws:sts::111122223333:user/janedoe", "accountId": "111122223333", "userName": "janedoe" }, "attributes": { "creationDate": "2021-08-02T23:40:45Z", "mfaAuthenticated": "false" } } }, "eventTime": "2021-08-02T23:40:58Z", "eventSource": "redshift.amazonaws.com", "eventName": "AuthorizeDataShare", "awsRegion": "us-east-1", "sourceIPAddress": "3.227.36.75", "userAgent":"aws-cli/1.18.118 Python/3.6.10 Linux/4.9.217-0.1.ac.205.84.332.metal1.x86_64 botocore/1.17.41", "requestParameters": { "dataShareArn": "arn:aws:redshift:us-east-1:111122223333:datashare:4c64c6ec-73d5-42be-869b-b7f7c43c7a53/testshare", "consumerIdentifier": "555555555555" }, "responseElements": { "dataShareArn": "arn:aws:redshift:us-east-1:111122223333:datashare:4c64c6ec-73d5-42be-869b-b7f7c43c7a53/testshare", "producerNamespaceArn": "arn:aws:redshift:us-east-1:123456789012:namespace:4c64c6ec-73d5-42be-869b-b7f7c43c7a53", "producerArn": "arn:aws:redshift:us-east-1:111122223333:namespace:4c64c6ec-73d5-42be-869b-b7f7c43c7a53", "allowPubliclyAccessibleConsumers": true, "dataShareAssociations": [ { "consumerIdentifier": "555555555555", "status": "AUTHORIZED", "createdDate": "Aug 2, 2021 11:40:56 PM", "statusChangeDate": "Aug 2, 2021 11:40:57 PM" } ] }, "requestID": "87ee1c99-9e41-42be-a5c4-00495f928422", "eventID": "03a3d818-37c8-46a6-aad5-0151803bdb09", "readOnly": false, "eventType": "AwsApiCall", "managementEvent": true, "recipientAccountId": "111122223333", "eventCategory": "Management" }

Amazon Redshift Serverless 範例

Amazon Redshift 無伺服器已與整合,AWS CloudTrail以提供在 Amazon Redshift 無伺服器中採取的動作記錄。 CloudTrail 擷取 Amazon Redshift 無伺服器的所有 API 呼叫作為事件。如需 Amazon Redshift Serverless 功能的詳細資訊,請參閱 Amazon Redshift Serverless 功能概觀

下列範例顯示示範CreateNamespace動作的 CloudTrail 記錄項目。

{ "eventVersion": "1.08", "userIdentity": { "type": "AssumedRole", "principalId": "AAKEOFPINEXAMPLE:admin", "arn": "arn:aws:sts::111111111111:assumed-role/admin/admin", "accountId": "111111111111", "accessKeyId": "AAKEOFPINEXAMPLE", "sessionContext": { "sessionIssuer": { "type": "Role", "principalId": "AAKEOFPINEXAMPLE", "arn": "arn:aws:iam::111111111111:role/admin", "accountId": "111111111111", "userName": "admin" }, "webIdFederationData": {}, "attributes": { "creationDate": "2022-03-21T20:51:58Z", "mfaAuthenticated": "false" } } }, "eventTime": "2022-03-21T23:15:40Z", "eventSource": "redshift-serverless.amazonaws.com", "eventName": "CreateNamespace", "awsRegion": "us-east-1", "sourceIPAddress": "56.23.155.33", "userAgent": "aws-cli/2.4.14 Python/3.8.8 Linux/5.4.181-109.354.amzn2int.x86_64 exe/x86_64.amzn.2 prompt/off command/redshift-serverless.create-namespace", "requestParameters": { "adminUserPassword": "HIDDEN_DUE_TO_SECURITY_REASONS", "adminUsername": "HIDDEN_DUE_TO_SECURITY_REASONS", "dbName": "dev", "namespaceName": "testnamespace" }, "responseElements": { "namespace": { "adminUsername": "HIDDEN_DUE_TO_SECURITY_REASONS", "creationDate": "Mar 21, 2022 11:15:40 PM", "defaultIamRoleArn": "", "iamRoles": [], "logExports": [], "namespaceArn": "arn:aws:redshift-serverless:us-east-1:111111111111:namespace/befa5123-16c2-4449-afca-1d27cb40fc99", "namespaceId": "8b726a0c-16ca-4799-acca-1d27cb403599", "namespaceName": "testnamespace", "status": "AVAILABLE" } }, "requestID": "ed4bb777-8127-4dae-aea3-bac009999163", "eventID": "1dbee944-f889-4beb-b228-7ad0f312464", "readOnly": false, "eventType": "AwsApiCall", "managementEvent": true, "recipientAccountId": "111111111111", "eventCategory": "Management", }

Amazon Redshift 資料 API 範例

下列範例顯示示範ExecuteStatement動作的 CloudTrail 記錄項目。

{ "eventVersion":"1.05", "userIdentity":{ "type":"IAMUser", "principalId":"AKIAIOSFODNN7EXAMPLE:janedoe", "arn":"arn:aws:sts::123456789012:user/janedoe", "accountId":"123456789012", "accessKeyId":"AKIAI44QH8DHBEXAMPLE", "userName": "janedoe" }, "eventTime":"2020-08-19T17:55:59Z", "eventSource":"redshift-data.amazonaws.com", "eventName":"ExecuteStatement", "awsRegion":"us-east-1", "sourceIPAddress":"192.0.2.0", "userAgent":"aws-cli/1.18.118 Python/3.6.10 Linux/4.9.217-0.1.ac.205.84.332.metal1.x86_64 botocore/1.17.41", "requestParameters":{ "clusterIdentifier":"example-cluster-identifier", "database":"example-database-name", "dbUser":"example_db_user_name", "sql":"***OMITTED***" }, "responseElements":{ "clusterIdentifier":"example-cluster-identifier", "createdAt":"Aug 19, 2020 5:55:58 PM", "database":"example-database-name", "dbUser":"example_db_user_name", "id":"5c52b37b-9e07-40c1-98de-12ccd1419be7" }, "requestID":"00c924d3-652e-4939-8a7a-cd0612eeb8ac", "eventID":"c1fb7076-102f-43e5-9ec9-40820bcc1175", "readOnly":false, "eventType":"AwsApiCall", "recipientAccountId":"123456789012" }

下列範例顯示了一個 CloudTrail 記錄項目,該記錄項目示範了clientToken用於冪等性的ExecuteStatement動作。

{ "eventVersion":"1.05", "userIdentity":{ "type":"IAMUser", "principalId":"AKIAIOSFODNN7EXAMPLE:janedoe", "arn":"arn:aws:sts::123456789012:user/janedoe", "accountId":"123456789012", "accessKeyId":"AKIAI44QH8DHBEXAMPLE", "userName": "janedoe" }, "eventTime":"2020-08-19T17:55:59Z", "eventSource":"redshift-data.amazonaws.com", "eventName":"ExecuteStatement", "awsRegion":"us-east-1", "sourceIPAddress":"192.0.2.0", "userAgent":"aws-cli/1.18.118 Python/3.6.10 Linux/4.9.217-0.1.ac.205.84.332.metal1.x86_64 botocore/1.17.41", "requestParameters":{ "clusterIdentifier":"example-cluster-identifier", "database":"example-database-name", "dbUser":"example_db_user_name", "sql":"***OMITTED***", "clientToken":"32db2e10-69ac-4534-b3fc-a191052616ce" }, "responseElements":{ "clusterIdentifier":"example-cluster-identifier", "createdAt":"Aug 19, 2020 5:55:58 PM", "database":"example-database-name", "dbUser":"example_db_user_name", "id":"5c52b37b-9e07-40c1-98de-12ccd1419be7" }, "requestID":"00c924d3-652e-4939-8a7a-cd0612eeb8ac", "eventID":"c1fb7076-102f-43e5-9ec9-40820bcc1175", "readOnly":false, "eventType":"AwsApiCall", "recipientAccountId":"123456789012" }

Amazon Redshift 查詢編輯器 v2 範例

下列範例顯示示範CreateConnection動作的 CloudTrail 記錄項目。

{ "eventVersion": "1.08", "userIdentity": { "type": "AssumedRole", "principalId": "AAKEOFPINEXAMPLE:session", "arn": "arn:aws:sts::123456789012:assumed-role/MyRole/session", "accountId": "123456789012", "accessKeyId": "AKIAI44QH8DHBEXAMPLE", "sessionContext": { "sessionIssuer": { "type": "Role", "principalId": "AAKEOFPINEXAMPLE", "arn": "arn:aws:iam::123456789012:role/MyRole", "accountId": "123456789012", "userName": "MyRole" }, "webIdFederationData": {}, "attributes": { "creationDate": "2022-09-21T17:19:02Z", "mfaAuthenticated": "false" } } }, "eventTime": "2022-09-21T22:22:05Z", "eventSource": "sqlworkbench.amazonaws.com", "eventName": "CreateConnection", "awsRegion": "ca-central-1", "sourceIPAddress": "192.2.0.2", "userAgent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Firefox/102.0", "requestParameters": { "password": "***", "databaseName": "***", "isServerless": false, "name": "***", "host": "redshift-cluster-2.c8robpbxvbf9.ca-central-1.redshift.amazonaws.com", "authenticationType": "***", "clusterId": "redshift-cluster-2", "username": "***", "tags": { "sqlworkbench-resource-owner": "AAKEOFPINEXAMPLE:session" } }, "responseElements": { "result": true, "code": "", "data": { "id": "arn:aws:sqlworkbench:ca-central-1:123456789012:connection/ce56b1be-dd65-4bfb-8b17-12345123456", "name": "***", "authenticationType": "***", "databaseName": "***", "secretArn": "arn:aws:secretsmanager:ca-central-1:123456789012:secret:sqlworkbench!7da333b4-9a07-4917-b1dc-12345123456-qTCoFm", "clusterId": "redshift-cluster-2", "dbUser": "***", "userSettings": "***", "recordDate": "2022-09-21 22:22:05", "updatedDate": "2022-09-21 22:22:05", "accountId": "123456789012", "tags": { "sqlworkbench-resource-owner": "AAKEOFPINEXAMPLE:session" }, "isServerless": false } }, "requestID": "9b82f483-9c03-4cdd-bb49-a7009e7da714", "eventID": "a7cdd442-e92f-46a2-bc82-2325588d41c3", "readOnly": false, "eventType": "AwsApiCall", "managementEvent": true, "recipientAccountId": "123456789012", "eventCategory": "Management" }

AWS CloudTrail 日誌中的 Amazon Redshift 帳戶 ID

當 Amazon Redshift 代表您呼叫另一個 AWS 服務時,即會使用屬於 Amazon Redshift 的帳戶 ID 來記錄呼叫。而不會使用您的帳戶 ID 來記錄呼叫。例如,假設 Amazon Redshift 呼叫 AWS Key Management Service (AWS KMS) 操作 (例如 CreateGrantDecryptEncryptRetireGrant) 來管理叢集上的加密。在此情況下,AWS CloudTrail 會使用 Amazon Redshift 帳戶 ID 來記錄呼叫。

呼叫其他 AWS 服務時,Amazon Redshift 會使用下表中的帳戶 ID。

區域 區域 帳戶 ID
美國東部 (維吉尼亞北部) 區域 us-east-1 368064434614
美國東部 (俄亥俄) 區域 us-east-2 790247189693
美國西部 (加利佛尼亞北部) 區域 us-west-1 703715109447
美國西部 (奧勒岡) 區域 us-west-2 473191095985
非洲 (開普敦) 區域 af-south-1 420376844563
亞太區域 (香港) 區域 ap-east-1 651179539253
亞太區域 (海德拉巴) ap-south-2 297058826802
亞太區域 (雅加達) ap-southeast-3 623197973179
亞太區域 (墨爾本) 區域 ap-southeast-4 945512339897
亞太 (孟買) 區域 ap-south-1 408097707231
亞太 (大阪) 區域 ap-northeast-3 398671365691
亞太 (首爾) 區域 ap-northeast-2 713597048934
亞太 (新加坡) 區域 ap-southeast-1 960118270566
亞太 (雪梨) 區域 ap-southeast-2 485979073181
亞太 (東京) 區域 ap-northeast-1 615915377779
加拿大 (中部) 區域 ca-central-1 764870610256
加拿大西部 (卡加利) 區域 ca-west-1 830903446466
歐洲 (法蘭克福) 區域 eu-central-1 434091160558
歐洲 (愛爾蘭) 區域 eu-west-1 246478207311
歐洲 (倫敦) 區域 eu-west-2 885798887673
Europe (Milan) Region eu-south-1 041313461515
歐洲 (巴黎) 區域 eu-west-3 694668203235
歐洲 (西班牙) 區域 eu-south-2 028811157404
歐洲 (斯德哥爾摩) 區域 eu-north-1 553461782468
歐洲 (蘇黎世) 區域 eu-central-2 668912161003
以色列 (特拉維夫) 區域 il-central-1 901883065212
Middle East (Bahrain) Region me-south-1 051362938876
中東 (阿拉伯聯合大公國) 區域 me-central-1 595013617770
南美洲 (聖保羅) 區域 sa-east-1 392442076723

下列範例顯示 Amazon Redshift 所呼叫之「AWS KMS解密」作業的 CloudTrail 日誌項目。

{ "eventVersion": "1.05", "userIdentity": { "type": "AssumedRole", "principalId": "AROAI5QPCMKLTL4VHFCYY:i-0f53e22dbe5df8a89", "arn": "arn:aws:sts::790247189693:assumed-role/prod-23264-role-wp/i-0f53e22dbe5df8a89", "accountId": "790247189693", "accessKeyId": "AKIAIOSFODNN7EXAMPLE", "sessionContext": { "attributes": { "mfaAuthenticated": "false", "creationDate": "2017-03-03T16:24:54Z" }, "sessionIssuer": { "type": "Role", "principalId": "AROAI5QPCMKLTL4VHFCYY", "arn": "arn:aws:iam::790247189693:role/prod-23264-role-wp", "accountId": "790247189693", "userName": "prod-23264-role-wp" } } }, "eventTime": "2017-03-03T17:16:51Z", "eventSource": "kms.amazonaws.com", "eventName": "Decrypt", "awsRegion": "us-east-2", "sourceIPAddress": "52.14.143.61", "userAgent": "aws-internal/3", "requestParameters": { "encryptionContext": { "aws:redshift:createtime": "20170303T1710Z", "aws:redshift:arn": "arn:aws:redshift:us-east-2:123456789012:cluster:my-dw-instance-2" } }, "responseElements": null, "requestID": "30d2fe51-0035-11e7-ab67-17595a8411c8", "eventID": "619bad54-1764-4de4-a786-8898b0a7f40c", "readOnly": true, "resources": [ { "ARN": "arn:aws:kms:us-east-2:123456789012:key/f8f4f94f-e588-4254-b7e8-078b99270be7", "accountId": "123456789012", "type": "AWS::KMS::Key" } ], "eventType": "AwsApiCall", "recipientAccountId": "123456789012", "sharedEventID": "c1daefea-a5c2-4fab-b6f4-d8eaa1e522dc" }