

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

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

AWS 支援 已與 服務整合 AWS CloudTrail，此服務可提供使用者、角色或 AWS 服務在其中採取之動作的記錄 AWS 支援。CloudTrail 會將 的 API 呼叫擷取 AWS 支援 為事件。擷取的呼叫包括來自 AWS 支援 主控台的呼叫，以及對 AWS 支援 API 操作的程式碼呼叫。

如果您建立追蹤，您可以將 CloudTrail 事件持續交付至 Amazon Simple Storage Service (Amazon S3) 儲存貯體，包括 的事件 AWS 支援。即使您未設定追蹤，依然可以透過 CloudTrail 主控台中的 **Event history (事件歷史記錄)** 檢視最新事件。

您可以利用 CloudTrail 所收集的資訊來判斷向 AWS 支援發出的請求，以及發出請求的 IP 地址、人員、時間和其他詳細資訊。

若要進一步了解 CloudTrail，包括如何設定及啟用，請參閱《[AWS CloudTrail 使用者指南](https://docs.aws.amazon.com/awscloudtrail/latest/userguide/)》。

## AWS 支援 CloudTrail 中的資訊
<a name="aws-support-info-in-cloudtrail-history"></a>

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

若要持續記錄您 AWS 帳戶中的事件，包括 的事件 AWS 支援，請建立*追蹤*。線索能讓 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 會記錄所有 AWS 支援 API 操作，並記錄在 [AWS 支援 API 參考](https://docs.aws.amazon.com/awssupport/latest/APIReference/)中。

例如，對 `CreateCase`、`DescribeCases` 和 `ResolveCase` 作業的呼叫都會在 CloudTrail 日誌檔案中產生項目。

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

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

您也可以將多個 AWS 區域和多個 AWS 帳戶的 AWS 支援 日誌檔案彙整至單一 Amazon S3 儲存貯體。

## AWS Trusted Advisor CloudTrail 日誌中的資訊
<a name="cloudtrail-logging-for-trusted-advisor"></a>

Trusted Advisor 是一項 AWS 支援 服務，可用來檢查 AWS 您的帳戶是否有節省成本、改善安全性和最佳化帳戶的方法。

CloudTrail 會記錄所有 Trusted Advisor API 操作，並記錄在 [AWS 支援 API 參考](https://docs.aws.amazon.com/awssupport/latest/APIReference/)中。

例如，對 `DescribeTrustedAdvisorCheckRefreshStatuses`、`DescribeTrustedAdvisorCheckResult` 和 `RefreshTrustedAdvisorCheck` 作業的呼叫都會在 CloudTrail 日誌檔案中產生項目。

**注意**  
CloudTrail 也會記錄 Trusted Advisor 主控台動作。請參閱 [使用 記錄 AWS Trusted Advisor 主控台動作 AWS CloudTrail](logging-using-cloudtrail-for-aws-trusted-advisor.md)。

## 了解 AWS 支援 日誌檔案項目
<a name="understanding-aws-support-entries"></a>

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

**Example ：CreateCase 的日誌項目**  
以下範例顯示 [CreateCase](https://docs.aws.amazon.com/awssupport/latest/APIReference/API_CreateCase.html) 作業的 CloudTrail 日誌項目。  

```
{
   "Records": [
      {
         "eventVersion": "1.04",
         "userIdentity": {
            "type": "IAMUser",
            "principalId": "AIDACKCEVSQ6C2EXAMPLE",
            "arn": "arn:aws:iam::111122223333:user/janedoe",
            "accountId": "111122223333",
            "accessKeyId": "AKIAIOSFODNN7EXAMPLE",
            "userName": "janedoe",
            "sessionContext": {
               "attributes": {
                  "mfaAuthenticated": "false",
                  "creationDate": "2016-04-13T17:51:37Z"
               }
            },
            "invokedBy": "signin.amazonaws.com"
         },
         "eventTime": "2016-04-13T18:05:53Z",
         "eventSource": "support.amazonaws.com",
         "eventName": "CreateCase",
         "awsRegion": "us-east-1",
         "sourceIPAddress": "198.51.100.15",
         "userAgent": "signin.amazonaws.com",
         "requestParameters": {
            "severityCode": "low",
            "categoryCode": "other",
            "language": "en",
            "serviceCode": "support-api",
            "issueType": "technical"
         },
         "responseElements": {
            "caseId": "case-111122223333-muen-2016-c3f2077e504940f2"
         },
         "requestID": "58c257ef-01a2-11e6-be2a-01c031063738",
         "eventID": "5aa34bfc-ad5b-4fb1-8a55-2277c86e746a",
         "eventType": "AwsApiCall",
         "recipientAccountId": "111122223333"
      }
   ],
   ...
}
```

**Example ：RefreshTrustedAdvisorCheck 的日誌項目**  
以下範例顯示 [RefreshTrustedAdvisorCheck](https://docs.aws.amazon.com/awssupport/latest/APIReference/API_RefreshTrustedAdvisorCheck.html) 作業的 CloudTrail 日誌項目。  

```
{
    "eventVersion": "1.05",
    "userIdentity": {
        "type": "IAMUser",
        "principalId": "AIDACKCEVSQ6C2EXAMPLE",
        "arn": "arn:aws:iam::111122223333:user/Admin",
        "accountId": "111122223333",
        "accessKeyId": "AKIAIOSFODNN7EXAMPLE",
        "userName": "Admin"
    },
    "eventTime": "2020-10-21T16:34:13Z",
    "eventSource": "support.amazonaws.com",
    "eventName": "RefreshTrustedAdvisorCheck",
    "awsRegion": "us-east-1",
    "sourceIPAddress": "72.21.198.67",
    "userAgent": "signin.amazonaws.com",
    "requestParameters": {
        "checkId": "Pfx0RwqBli"
    },
    "responseElements": null,
    "requestID": "4c4d5fc8-c403-4f82-9544-41f820e0fa01",
    "eventID": "2f4630ac-5c27-4f0d-b93f-63742d6fc85e",
    "eventType": "AwsApiCall",
    "recipientAccountId": "111122223333"
}
```