

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

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

AWS Elemental MediaLive 已與 整合 AWS CloudTrail，CloudTrail 是提供使用者、角色或服務所採取動作記錄的服務 AWS 。CloudTrail 會將 MediaLive 的所有 API 呼叫擷取為事件。擷取的呼叫包括來自 MediaLive 主控台的呼叫，以及對 MediaLive API 操作的程式碼呼叫。如果您建立線索，您可以將 CloudTrail 事件持續交付至 Amazon S3 儲存貯體，包括 MediaLive 的事件。即使您未設定追蹤，依然可以透過 CloudTrail 主控台中的**事件歷史記錄**檢視最新事件。您可以使用 CloudTrail 所收集的資訊，判斷對 MediaLive 提出的請求、提出請求的 IP 地址、提出請求的人員、提出請求的時間，以及其他詳細資訊。

若要進一步了解 CloudTrail，請參閱[「AWS CloudTrail 使用者指南」](https://docs.aws.amazon.com/awscloudtrail/latest/userguide/)。

## CloudTrail 中的 MediaLive 資訊
<a name="medialive-info-in-cloudtrail"></a>

當您建立 AWS 帳戶時，會在您的帳戶上啟用 CloudTrail。當活動在 MediaLive 中發生時，該活動會與**事件歷史記錄**中的其他服務 AWS 事件一起記錄在 CloudTrail 事件中。您可以在 AWS 帳戶中檢視、搜尋和下載最近的事件。如需詳細資訊，請參閱《使用 CloudTrail 事件歷史記錄檢視事件》[https://docs.aws.amazon.com/awscloudtrail/latest/userguide/view-cloudtrail-events.html](https://docs.aws.amazon.com/awscloudtrail/latest/userguide/view-cloudtrail-events.html)。

若要持續記錄您 AWS 帳戶中的事件，包括 MediaLive 的事件，請建立追蹤。*線索*能讓 CloudTrail 將日誌檔案交付至 Amazon S3 儲存貯體。根據預設，當您在主控台中建立線索時，線索會套用至所有 AWS 區域。線索會記錄 AWS 分割區中所有區域的事件，並將日誌檔案傳送到您指定的 Amazon S3 儲存貯體。此外，您可以設定其他 AWS 服務，以進一步分析和處理 CloudTrail 日誌中所收集的事件資料。如需詳細資訊，請參閱下列內容：
+ [建立追蹤的概觀](https://docs.aws.amazon.com/awscloudtrail/latest/userguide/cloudtrail-create-and-update-a-trail.html)
+ [CloudTrail 支援的服務和整合](https://docs.aws.amazon.com/awscloudtrail/latest/userguide/cloudtrail-aws-service-specific-topics.html#cloudtrail-aws-service-specific-topics-integrations)
+ [設定 CloudTrail 的 Amazon SNS 通知](https://docs.aws.amazon.com/awscloudtrail/latest/userguide/getting_notifications_top_level.html)
+ [從多個區域接收 CloudTrail 日誌檔案](https://docs.aws.amazon.com/awscloudtrail/latest/userguide/receive-cloudtrail-log-files-from-multiple-regions.html)，以及[從多個帳戶接收 CloudTrail 日誌檔案](https://docs.aws.amazon.com/awscloudtrail/latest/userguide/cloudtrail-receive-logs-from-multiple-accounts.html)

CloudTrail 會記錄所有 MediaLive 動作，並記錄在 https：//https://docs.aws.amazon.com/medialive/latest/apireference/。

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

如需詳細資訊，請參閱 [CloudTrail userIdentity Element](https://docs.aws.amazon.com/awscloudtrail/latest/userguide/cloudtrail-event-reference-user-identity.html)。

## 了解 MediaLive 日誌檔案項目
<a name="understanding-medialive-entries"></a>

追蹤是一種組態，能讓事件以日誌檔案的形式交付到您指定的 Amazon S3 儲存貯體。CloudTrail 日誌檔案包含一或多個日誌專案。一個事件為任何來源提出的單一請求，並包含請求動作、請求的日期和時間、請求參數等資訊。CloudTrail 日誌檔並非依公有 API 呼叫的堆疊追蹤排序，因此不會以任何特定順序出現。

下列範例顯示 CloudTrail 日誌項目。範例顯示 API 呼叫的項目。呼叫是由 中指定的身分進行`userIdentity`，在此情況下，使用者名稱為 的使用者`santosp`。呼叫是來自執行 IP 地址 203.0.113.33 之 AWS CLI 電腦上的 (如 `userAgent` 中所指定) `CreateInput` 操作：

```
    {
   “eventVersion”: “1.05",
   “userIdentity”: {
       “type”: “IAMUser”,
       “principalId”: “AIDACKCEVSQ6C2EXAMPLE”,
       “arn”: “arn:aws:iam::111122223333:user/santosp”,
       “accountId”: “111122223333”,
       “accessKeyId”: “AKIAOSFODNN7EXAMPLE”,
       “userName”: “santosp”
   },
   “eventTime”: “2019-01-17T21:21:17Z”,
   “eventSource”: “medialive.amazonaws.com”,
   “eventName”: “CreateInput”,
   “awsRegion”: “us-west-2”,
   “sourceIPAddress”: “203.0.113.33”,
   “userAgent”: “aws-cli/1.16.86 Python/2.7.15 Darwin/17.7.0 botocore/1.12.76”,
   “requestParameters”: {
       “mediaConnectFlows”: [],
       “inputSecurityGroups”: [
           “9999999”
       ],
       “sources”: [],
       “roleArn”: “MediaLiveAccessRole”,
       “requestId”: “1111aaaa-9604-4459-a160-46a28ae166",
       “name”: “live-studio-feed”,
       “type”: “RTP_PUSH”,
       }
   },
   “responseElements”: {
       “input”: {
           “arn”: “arn:aws:medialive:us-west-2:111122223333:input:7780651”,
           “id”: “7780651”,
           “name”: “live-studio-feed”,
           “type”: “RTP_PUSH”,
           “sources”: [],
           “destinations”: [
               {
                   “url”: “rtp://198.51.100.10:1935”,
                   “ip”: “198.51.100.10:1935”,
                   “port”: “1935”
               },
               {
                   “url”: “rtp://192.0.2.131:1935”,
                   “ip”: “192.0.2.131:1935”,
                   “port”: “1935”
               }
           ],
           “mediaConnectFlows”: [],
           “state”: “DETACHED”,
           “attachedChannels”: [],
           “securityGroups”: [
               “9999999”
           ],
           “roleArn”: “”
       }
   },
   “requestID”: “d2f882ac-1a9d-11e9-a0e5-afe6a8c88993”,
   “eventID”: “ebbe0290-7a1b-4053-a219-367404e0fe96”,
   “readOnly”: false,
   “eventType”: “AwsApiCall”,
   “recipientAccountId”: “111122223333"
}
```