

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

# 使用记录 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 服务发出。

CloudTrail 在您创建账户 AWS 账户 时在您的账户中处于活动状态，并且您自动可以访问 CloudTrail **活动历史记录**。 CloudTrail **事件历史记录**提供了过去 90 天中记录的管理事件的可查看、可搜索、可下载且不可变的记录。 AWS 区域有关更多信息，请参阅《*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)。  
通过创建跟踪，您可以免费将正在进行的管理事件的一份副本传送到您的 Amazon S3 存储桶，但是，会收取 Amazon S3 存储费用。 CloudTrail 有关 CloudTrail 定价的更多信息，请参阅[AWS CloudTrail 定价](https://aws.amazon.com/cloudtrail/pricing/)。有关 Amazon S3 定价的信息，请参阅 [Amazon S3 定价](https://aws.amazon.com/s3/pricing/)。

**CloudTrail 湖泊事件数据存储**  
CloudTrail L@@ *ak* e 允许您对事件运行基于 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 湖泊事件数据存储和查询会产生费用。创建事件数据存储时，您可以选择要用于事件数据存储的[定价选项](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/)。

## Amazon 将数据事件 GameLift 直播到 CloudTrail
<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 操作记录 Amazon GameLift Streams 资源类型的数据事件。 AWS CLI有关如何记录数据事件的更多信息，请参阅《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 台上的**资源类型**列表中选择的值。res **ources.type 值**列显示该`resources.type`值，您将在使用或配置高级事件选择器时指定该值。 AWS CLI CloudTrail APIs“** APIs 记录到的数据 CloudTrail**” 列显示了 CloudTrail 针对该资源类型记录的 API 调用。


| 资源类型（控制台） | resources.type 值 | 数据 APIs 已记录到 CloudTrail | 
| --- | --- | --- | 
| GameLift 直播应用程序 |  AWS::GameLiftStreams::Application  |  [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_cn/gameliftstreams/latest/developerguide/logging-using-cloudtrail.html)  | 
| GameLift 直播群组 |  AWS::GameLiftStreams::StreamGroup  |  [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_cn/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)。

## Amazon GameLift 直播管理事件 CloudTrail
<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 录制内容](https://docs.aws.amazon.com/awscloudtrail/latest/userguide/cloudtrail-event-reference-record-contents.html)。