本文為英文版的機器翻譯版本,如內容有任何歧義或不一致之處,概以英文版為準。
使用 記錄 CloudTrail
Amazon Redshift、資料共用、Amazon Redshift ServerlessAPI、Amazon Redshift Data 和查詢編輯器 v2 都與 整合 AWS CloudTrail。 CloudTrail 是一種服務,可提供使用者、角色或 Amazon Redshift 中的 AWS 服務所採取動作的記錄。 會將 Amazon Redshift 的所有API呼叫 CloudTrail 擷取為事件。擷取的呼叫包括從 Redshift 主控台進行的呼叫,以及針對 Redshift 操作的程式碼呼叫。
如果您建立 CloudTrail 追蹤,則可以將 CloudTrail 事件持續交付至 Amazon S3 儲存貯體,包括 Redshift 的事件。如果您未設定追蹤,仍然可以在 事件歷史記錄 中檢視 CloudTrail 主控台中的最新事件。 使用 收集的資訊 CloudTrail,您可以判斷某些物件。這些事情包括向 Redshift 提出的請求、提出請求的 IP 地址、提出請求的人員、提出請求的時間,以及其他詳細資訊。
除了 Amazon Redshift 資料庫稽核記錄之外,您也可以 CloudTrail 獨立使用 或 。
若要進一步了解 CloudTrail,請參閱 AWS CloudTrail 使用者指南 。
中的資訊 CloudTrail
CloudTrail 當您建立 AWS 帳戶時, 會在您的帳戶中開啟。活動發生時,該活動會與 CloudTrail 事件歷史記錄 中的其他 AWS 服務事件一起記錄在事件中。您可以在 AWS 帳戶中檢視、搜尋和下載最近的事件。如需詳細資訊,請參閱 AWS CloudTrail 使用者指南 中的使用事件歷史記錄檢視 CloudTrail 事件。
如需 AWS 帳戶中事件的持續記錄,包括 Redshift 的事件,請建立 trail. CloudTrail uses trails,將日誌檔案傳遞至 Amazon S3 儲存貯體。根據預設,當您在主控台建立線索時,線索會套用到所有 AWS 區域。追蹤會記錄 AWS 分割區中所有 區域的事件,並將日誌檔案傳送到您指定的 Amazon S3 儲存貯體。此外,您可以設定其他 AWS 服務,以進一步分析 CloudTrail 日誌中收集的事件資料並對其採取行動。如需詳細資訊,請參閱《AWS CloudTrail 使用者指南》 中的下列主題:
所有 Amazon Redshift、Amazon Redshift Serverless、資料 API、資料共用和查詢編輯器 v2 動作都會由 記錄 CloudTrail。例如,呼叫 AuthorizeDatashare
、CreateNamespace
、 ExecuteStatement
和 CreateConnection
動作會在 CloudTrail 日誌檔案中產生項目。
每一筆事件或日誌專案都會包含產生請求者的資訊。身分資訊可協助您判斷下列事項:
-
該請求是否使用根或使用者憑證提出。
-
提出該請求時,是否使用了特定角色或聯合身分使用者的暫時安全憑證。
-
該請求是否由其他 AWS 服務提出。
如需詳細資訊,請參閱 AWS CloudTrail 使用者指南 中的CloudTrail userIdentity元素。
日誌檔案項目
追蹤是一種組態,允許將事件作為日誌檔案交付到您指定的 Amazon S3 儲存貯體。 CloudTrail 日誌檔案包含一或多個日誌項目。事件代表來自任何來源的單一請求,並包含所請求動作、動作日期和時間、請求參數等資訊。 CloudTrail log 檔案不是公開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 Serverless 與 整合 AWS CloudTrail ,以提供在 Amazon Redshift Serverless. CloudTrail Captures 中對 Amazon Redshift Serverless 進行的所有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 Data 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 日誌項目,其中示範ExecuteStatement
了顯示clientToken
用於意識模糊的動作。
{ "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 日誌IDs中的 Amazon Redshift 帳戶
當 Amazon Redshift 為您呼叫另一項 AWS 服務時,系統會使用屬於 Amazon Redshift 的帳戶 ID 記錄通話。而不會使用您的帳戶 ID 來記錄呼叫。例如,假設 Amazon Redshift 呼叫 AWS Key Management Service (AWS KMS) 操作,例如 CreateGrant
、Encrypt
、 Decrypt
和 RetireGrant
來管理叢集上的加密。在此情況下, AWS CloudTrail 會使用 Amazon Redshift 帳戶 ID 記錄通話。
Amazon Redshift 會在呼叫其他服務 AWS 時使用下表IDs中的 帳戶。
區域 | 區域 | 帳戶 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-5 | 590184011157 |
亞太區域 (墨爾本) 區域 | 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 |
中東 (UAE) 區域 | 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" }