

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

# 使用 記錄 Amazon GameLift Streams API 呼叫 AWS CloudTrail
<a name="logging-using-cloudtrail"></a>

Amazon GameLift Streams 已與 整合[AWS CloudTrail](https://docs.aws.amazon.com/awscloudtrail/latest/userguide/cloudtrail-user-guide.html)，這項服務可提供使用者、角色或 所採取動作的記錄 AWS 服務。CloudTrail 會將 Amazon GameLift Streams 的所有 API 呼叫擷取為事件。擷取的呼叫包括來自 Amazon GameLift Streams 主控台的呼叫，以及對 Amazon GameLift Streams API 操作的程式碼呼叫。您可以使用 CloudTrail 所收集的資訊，判斷對 Amazon GameLift Streams 提出的請求、提出請求的 IP 地址、提出請求的時間，以及其他詳細資訊。

每一筆事件或日誌專案都會包含產生請求者的資訊。身分資訊可協助您判斷下列事項：
+ 該請求是使用根使用者還是使用者憑證提出。
+ 請求是否代表 IAM Identity Center 使用者提出。
+ 提出該請求時，是否使用了特定角色或聯合身分使用者的暫時安全憑證。
+ 該請求是否由另一項 AWS 服務服務提出。

當您建立帳戶 AWS 帳戶 時CloudTrail 會在您的 中處於作用中狀態，而且您會自動存取 CloudTrail **事件歷史記錄**。CloudTrail **事件歷史記錄**為 AWS 區域中過去 90 天記錄的管理事件，提供可檢視、可搜尋、可下載且不可變的記錄。如需詳細資訊，請參閱「AWS CloudTrail 使用者指南」**中的[使用 CloudTrail 事件歷史記錄](https://docs.aws.amazon.com/awscloudtrail/latest/userguide/view-cloudtrail-events.html)。檢視**事件歷史記錄**不會產生 CloudTrail 費用。

如需 AWS 帳戶 過去 90 天內持續記錄的事件，請建立線索或 [CloudTrail Lake](https://docs.aws.amazon.com/awscloudtrail/latest/userguide/cloudtrail-lake.html) 事件資料存放區。

**CloudTrail 追蹤**  
*線索*能讓 CloudTrail 將日誌檔案交付至 Amazon S3 儲存貯體。使用 建立的所有線索 AWS 管理主控台 都是多區域。您可以使用 AWS CLI建立單一或多區域追蹤。建議您建立多區域追蹤，因為您擷取 AWS 區域 帳戶中所有 的活動。如果您建立單一區域追蹤，您只能檢視追蹤 AWS 區域中記錄的事件。如需追蹤的詳細資訊，請參閱《AWS CloudTrail 使用者指南》**中的[為您的 AWS 帳戶建立追蹤](https://docs.aws.amazon.com/awscloudtrail/latest/userguide/cloudtrail-create-and-update-a-trail.html)和[為組織建立追蹤](https://docs.aws.amazon.com/awscloudtrail/latest/userguide/creating-trail-organization.html)。  
您可以透過建立追蹤，免費將持續管理事件的一個複本從 CloudTrail 傳遞至您的 Amazon S3 儲存貯體，但這樣做會產生 Amazon S3 儲存費用。如需 CloudTrail 定價的詳細資訊，請參閱 [AWS CloudTrail 定價](https://aws.amazon.com/cloudtrail/pricing/)。如需 Amazon S3 定價的相關資訊，請參閱 [Amazon S3 定價](https://aws.amazon.com/s3/pricing/)。

**CloudTrail Lake 事件資料存放區**  
*CloudTrail Lake* 讓您能夠對事件執行 SQL 型查詢。CloudTrail Lake 會將分列式 JSON 格式的現有事件轉換為 [Apache ORC](https://orc.apache.org/) 格式。ORC 是一種單欄式儲存格式，針對快速擷取資料進行了最佳化。系統會將事件彙總到*事件資料存放區*中，事件資料存放區是事件的不可變集合，其依據為您透過套用[進階事件選取器](https://docs.aws.amazon.com/awscloudtrail/latest/userguide/cloudtrail-lake-concepts.html#adv-event-selectors)選取的條件。套用於事件資料存放區的選取器控制哪些事件持續存在並可供您查詢。如需 CloudTrail Lake 的詳細資訊，請參閱*AWS CloudTrail 《 使用者指南*》中的[使用 AWS CloudTrail Lake](https://docs.aws.amazon.com/awscloudtrail/latest/userguide/cloudtrail-lake.html)。  
CloudTrail Lake 事件資料存放區和查詢會產生費用。建立事件資料存放區時，您可以選擇要用於事件資料存放區的[定價選項](https://docs.aws.amazon.com/awscloudtrail/latest/userguide/cloudtrail-lake-manage-costs.html#cloudtrail-lake-manage-costs-pricing-option)。此定價選項將決定擷取和儲存事件的成本，以及事件資料存放區的預設和最長保留期。如需 CloudTrail 定價的詳細資訊，請參閱 [AWS CloudTrail 定價](https://aws.amazon.com/cloudtrail/pricing/)。

## CloudTrail 中的 Amazon GameLift Streams 資料事件
<a name="cloudtrail-data-events"></a>

[資料事件](https://docs.aws.amazon.com/awscloudtrail/latest/userguide/logging-data-events-with-cloudtrail.html#logging-data-events)提供資源操作的相關資訊 （例如，在串流群組中啟動串流工作階段）。這些也稱為資料平面操作。資料事件通常是大量資料的活動。根據預設，CloudTrail 不會記錄資料事件。CloudTrail **事件歷史記錄**不會記錄資料事件。

資料事件需支付額外的費用。如需 CloudTrail 定價的詳細資訊，請參閱 [AWS CloudTrail 定價](https://aws.amazon.com/cloudtrail/pricing/)。

您可以使用 CloudTrail 主控台或 CloudTrail API 操作 AWS CLI，記錄 Amazon GameLift Streams 資源類型的資料事件。如需如何記錄資料事件的詳細資訊，請參閱《AWS CloudTrail 使用者指南》**中的[使用 AWS 管理主控台記錄資料事件](https://docs.aws.amazon.com/awscloudtrail/latest/userguide/logging-data-events-with-cloudtrail.html#logging-data-events-console)和[使用 AWS Command Line Interface記錄資料事件](https://docs.aws.amazon.com/awscloudtrail/latest/userguide/logging-data-events-with-cloudtrail.html#creating-data-event-selectors-with-the-AWS-CLI)。

下表列出您可以記錄資料事件的 Amazon GameLift Streams 資源類型。**資源類型 （主控台）** 欄顯示從 CloudTrail 主控台上的**資源類型**清單中選擇的值。**resources.type 值**欄會顯示值，您會在使用 AWS CLI 或 CloudTrail APIs 設定進階事件選取器時指定此`resources.type`值。**記錄到 CloudTrail 的資料 API** 資料行會針對資源類型顯示記錄到 CloudTrail 的 API 呼叫。


| 資源類型 （主控台） | resources.type 值 | 記錄到 CloudTrail 的資料 API | 
| --- | --- | --- | 
| GameLift Streams 應用程式 |  AWS::GameLiftStreams::Application  |  [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/gameliftstreams/latest/developerguide/logging-using-cloudtrail.html)  | 
| GameLift Streams 串流群組 |  AWS::GameLiftStreams::StreamGroup  |  [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/gameliftstreams/latest/developerguide/logging-using-cloudtrail.html)  | 

您可以設定進階事件選取器來篩選 `eventName`、`readOnly` 和 `resources.ARN` 欄位，以僅記錄對您重要的事件。如需這些欄位的詳細資訊，請參閱AWS CloudTrail API 參考**中的[https://docs.aws.amazon.com/awscloudtrail/latest/APIReference/API_AdvancedFieldSelector.html](https://docs.aws.amazon.com/awscloudtrail/latest/APIReference/API_AdvancedFieldSelector.html)。

## CloudTrail 中的 Amazon GameLift Streams 管理事件
<a name="cloudtrail-management-events"></a>

[管理事件](https://docs.aws.amazon.com/awscloudtrail/latest/userguide/logging-management-events-with-cloudtrail.html#logging-management-events)提供有關在 資源上執行的管理操作的資訊 AWS 帳戶。這些也稱為控制平面操作。根據預設，CloudTrail 記錄管理事件。

Amazon GameLift Streams 會將下列 Amazon GameLift Streams 控制平面操作記錄到 CloudTrail 作為*管理事件*。
+ [https://docs.aws.amazon.com/gameliftstreams/latest/apireference/API_AddStreamGroupLocations.html](https://docs.aws.amazon.com/gameliftstreams/latest/apireference/API_AddStreamGroupLocations.html)
+ [https://docs.aws.amazon.com/gameliftstreams/latest/apireference/API_AssociateApplications.html](https://docs.aws.amazon.com/gameliftstreams/latest/apireference/API_AssociateApplications.html)
+ [https://docs.aws.amazon.com/gameliftstreams/latest/apireference/API_CreateApplication.html](https://docs.aws.amazon.com/gameliftstreams/latest/apireference/API_CreateApplication.html)
+ [https://docs.aws.amazon.com/gameliftstreams/latest/apireference/API_CreateStreamGroup.html](https://docs.aws.amazon.com/gameliftstreams/latest/apireference/API_CreateStreamGroup.html)
+ [https://docs.aws.amazon.com/gameliftstreams/latest/apireference/API_DeleteApplication.html](https://docs.aws.amazon.com/gameliftstreams/latest/apireference/API_DeleteApplication.html)
+ [https://docs.aws.amazon.com/gameliftstreams/latest/apireference/API_DeleteStreamGroup.html](https://docs.aws.amazon.com/gameliftstreams/latest/apireference/API_DeleteStreamGroup.html)
+ [https://docs.aws.amazon.com/gameliftstreams/latest/apireference/API_DisassociateApplications.html](https://docs.aws.amazon.com/gameliftstreams/latest/apireference/API_DisassociateApplications.html)
+ [https://docs.aws.amazon.com/gameliftstreams/latest/apireference/API_GetApplication.html](https://docs.aws.amazon.com/gameliftstreams/latest/apireference/API_GetApplication.html)
+ [https://docs.aws.amazon.com/gameliftstreams/latest/apireference/API_GetStreamGroup.html](https://docs.aws.amazon.com/gameliftstreams/latest/apireference/API_GetStreamGroup.html)
+ [https://docs.aws.amazon.com/gameliftstreams/latest/apireference/API_ListApplications.html](https://docs.aws.amazon.com/gameliftstreams/latest/apireference/API_ListApplications.html)
+ [https://docs.aws.amazon.com/gameliftstreams/latest/apireference/API_ListStreamGroups.html](https://docs.aws.amazon.com/gameliftstreams/latest/apireference/API_ListStreamGroups.html)
+ [https://docs.aws.amazon.com/gameliftstreams/latest/apireference/API_ListTagsForResource.html](https://docs.aws.amazon.com/gameliftstreams/latest/apireference/API_ListTagsForResource.html)
+ [https://docs.aws.amazon.com/gameliftstreams/latest/apireference/API_RemoveStreamGroupLocations.html](https://docs.aws.amazon.com/gameliftstreams/latest/apireference/API_RemoveStreamGroupLocations.html)
+ [https://docs.aws.amazon.com/gameliftstreams/latest/apireference/API_TagResource.html](https://docs.aws.amazon.com/gameliftstreams/latest/apireference/API_TagResource.html)
+ [https://docs.aws.amazon.com/gameliftstreams/latest/apireference/API_UntagResource.html](https://docs.aws.amazon.com/gameliftstreams/latest/apireference/API_UntagResource.html)
+ [https://docs.aws.amazon.com/gameliftstreams/latest/apireference/API_UpdateApplication.html](https://docs.aws.amazon.com/gameliftstreams/latest/apireference/API_UpdateApplication.html)
+ [https://docs.aws.amazon.com/gameliftstreams/latest/apireference/API_UpdateStreamGroup.html](https://docs.aws.amazon.com/gameliftstreams/latest/apireference/API_UpdateStreamGroup.html)

## Amazon GameLift Streams 事件範例
<a name="cloudtrail-event-examples"></a>

一個事件代表任何來源提出的單一請求，並包含請求 API 操作的相關資訊、操作的日期和時間、請求參數等。CloudTrail 日誌檔案不是公有 API 呼叫的已排序堆疊追蹤，因此事件不會以任何特定順序顯示。

下列範例顯示示範 [CreateApplication](https://docs.aws.amazon.com/gameliftstreams/latest/apireference/API_CreateApplication.html) 操作的 CloudTrail 管理事件。

```
{
      "eventVersion": "1.09",
      "userIdentity": {
         "type": "AssumedRole",
         "principalId": "AROA123456789EXAMPLE:assume-temporary-gameliftstreams-access-role",
         "arn": "arn:aws:sts::111122223333:assumed-role/GameLiftStreamsTestRole/assume-temporary-gameliftstreams-access-role",
         "accountId": "111122223333",
         "accessKeyId": "ASIAIOSFODNN7EXAMPLE",
         "sessionContext": {
               "sessionIssuer": {
                  "type": "Role",
                  "principalId": "AROA123456789EXAMPLE",
                  "arn": "arn:aws:iam::111122223333:role/GameLiftStreamsTestRole",
                  "accountId": "111122223333",
                  "userName": "GameLiftStreamsTestRole"
               },
               "webIdFederationData": {},
               "attributes": {
                  "creationDate": "2025-07-23T21:18:19Z",
                  "mfaAuthenticated": "false"
               }
         }
      },
      "eventTime": "2025-07-23T21:58:54Z",
      "eventSource": "gameliftstreams.amazonaws.com",
      "eventName": "CreateApplication",
      "awsRegion": "us-west-2",
      "sourceIPAddress": "203.0.113.0",
      "userAgent": "aws-sdk-javascript/2.0.0 Linux/4.14.291-218.527.amzn2.x86_64 OpenJDK_64-Bit_Server_VM/11.0.17+9-LTS Java/11.0.17 vendor/Amazon.com_Inc. exec-env/AWS_ECS_FARGATE io/sync http/Apache cfg/retry-mode/legacy",
      "requestParameters": {
         "ApplicationSourceUri": "s3://amzn-s3-demo-bucket/MyGame",
         "Description": "MyGame canary - Proton 8",
         "RuntimeEnvironment": {
               "Type": "PROTON",
               "Version": "20230704"
         },
         "ClientToken": "a1b2c3d4-5678-90ab-cdef-EXAMPLE33333",
         "ExecutablePath": "MyGame100.exe"
      },
      "responseElements": {
         "Status": "INITIALIZED",
         "ApplicationSourceUri": "s3://amzn-s3-demo-bucket/MyGame",
         "Description": "MyGame canary - Proton 8",
         "RuntimeEnvironment": {
               "Type": "PROTON",
               "Version": "20230704"
         },
         "LastUpdatedAt": 1753307934.293,
         "CreatedAt": 1753307934.293,
         "Id": "a-9ZY8X7Wv6",
         "Arn": "arn:aws:gameliftstreams:us-west-2:111122223333:application/a-9ZY8X7Wv6",
         "ExecutablePath": "MyGame100.exe"
      },
      "requestID": "a1b2c3d4-5678-90ab-cdef-EXAMPLE11111",
      "eventID": "a1b2c3d4-5678-90ab-cdef-EXAMPLEbbbbb",
      "readOnly": false,
      "eventType": "AwsApiCall",
      "managementEvent": true,
      "recipientAccountId": "111122223333",
      "eventCategory": "Management"
}
```

下列範例顯示來自追蹤日誌的 CloudTrail 資料事件，示範 [StartStreamSession](https://docs.aws.amazon.com/gameliftstreams/latest/apireference/API_StartStreamSession.html) 操作。

```
{
    "Records": [
        {
            "eventVersion": "1.09",
            "userIdentity": {
                "type": "AssumedRole",
                "principalId": "AROA123456789EXAMPLE:assume-temporary-gameliftstreams-access-role",
                "arn": "arn:aws:sts::111122223333:assumed-role/GameLiftStreamsTestRole/assume-temporary-gameliftstreams-access-role",
                "accountId": "111122223333",
                "accessKeyId": "ASIAIOSFODNN7EXAMPLE",
                "sessionContext": {
                    "sessionIssuer": {
                        "type": "Role",
                        "principalId": "AROA123456789EXAMPLE",
                        "arn": "arn:aws:iam::111122223333:role/GameLiftStreamsTestRole",
                        "accountId": "111122223333",
                        "userName": "GameLiftStreamsTestRole"
                    },
                    "attributes": {
                        "creationDate": "2025-07-23T21:18:19Z",
                        "mfaAuthenticated": "false"
                    }
                }
            },
            "eventTime": "2025-07-23T23:43:46Z",
            "eventSource": "gameliftstreams.amazonaws.com",
            "eventName": "StartStreamSession",
            "awsRegion": "us-east-2",
            "sourceIPAddress": "203.0.113.0",
            "userAgent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/138.0.0.0 Safari/537.36",
            "requestParameters": {
                "Identifier": "sg-1AB2C3De4",
                "Description": "StreamGroup sg-1AB2C3De4 Application a-9ZY8X7Wv6 Console stream",
                "AdditionalLaunchArgs": [],
                "UserId": "a1b2c3d4-5678-90ab-cdef-EXAMPLE11111",
                "Locations": [
                    "us-east-2"
                ],
                "SignalRequest": "***",
                "Protocol": "WebRTC",
                "ApplicationIdentifier": "a-9ZY8X7Wv6",
                "ClientToken": "a1b2c3d4-5678-90ab-cdef-EXAMPLE22222",
                "ConnectionTimeoutSeconds": 100,
                "AdditionalEnvironmentVariables": {}
            },
            "responseElements": {
                "Status": "ACTIVATING",
                "ApplicationArn": "arn:aws:gameliftstreams:us-west-2:111122223333:application/a-9ZY8X7Wv6",
                "Description": "StreamGroup sg-1AB2C3De4 Application a-9ZY8X7Wv6 Console stream",
                "LastUpdatedAt": 1.753314225925E9,
                "CreatedAt": 1.753314225925E9,
                "AdditionalEnvironmentVariables": {},
                "ConnectionTimeoutSeconds": 100,
                "AdditionalLaunchArgs": [],
                "StreamGroupId": "sg-1AB2C3De4",
                "UserId": "a1b2c3d4-5678-90ab-cdef-EXAMPLE11111",
                "SessionLengthSeconds": 43200,
                "SignalRequest": "***",
                "Arn": "arn:aws:gameliftstreams:us-west-2:111122223333:streamsession/sg-1AB2C3De4/ABC123def4567",
                "Protocol": "WebRTC",
                "WebSdkProtocolUrl": "https://123456789012.cloudfront.net/e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855.js"
            },
            "requestID": "a1b2c3d4-5678-90ab-cdef-EXAMPLEaaaaa",
            "eventID": "a1b2c3d4-5678-90ab-cdef-EXAMPLEbbbbb",
            "readOnly": false,
            "resources": [
                {
                    "accountId": "111122223333",
                    "type": "AWS::GameLiftStreams::StreamGroup",
                    "ARN": "arn:aws:gameliftstreams:us-west-2:111122223333:streamgroup/sg-1AB2C3De4"
                },
                {
                    "accountId": "111122223333",
                    "type": "AWS::GameLiftStreams::Application",
                    "ARN": "arn:aws:gameliftstreams:us-west-2:111122223333:application/a-9ZY8X7Wv6"
                }
            ],
            "eventType": "AwsApiCall",
            "managementEvent": false,
            "recipientAccountId": "111122223333",
            "eventCategory": "Data"
        }
    ]
}
```

如需有關 CloudTrail 記錄內容的資訊，請參閱《AWS CloudTrail 使用者指南》**中的 [CloudTrail record contents](https://docs.aws.amazon.com/awscloudtrail/latest/userguide/cloudtrail-event-reference-record-contents.html)。