

我們不再更新 Amazon Machine Learning 服務或接受新使用者。本文件可供現有使用者使用，但我們不再更新。如需詳細資訊，請參閱[什麼是 Amazon Machine Learning](https://docs.aws.amazon.com/machine-learning/latest/dg/what-is-amazon-machine-learning.html)。

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

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

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

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

## CloudTrail 中的 Amazon ML 資訊
<a name="service-name-info-in-cloudtrail"></a>

建立 AWS 帳戶時，會在您的帳戶上啟用 CloudTrail。當 Amazon ML 中發生支援的事件活動時，該活動會記錄於 CloudTrail 事件，以及**事件歷史記錄**中的其他服務 AWS 事件。您可以在 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 帳戶中的事件，包括 Amazon ML 的事件，請建立追蹤。*線索*能讓 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)

Amazon ML 支援將下列動作記錄為 CloudTrail 日誌檔案中的事件：
+ [AddTags](https://docs.aws.amazon.com/machine-learning/latest/APIReference/API_AddTags.html)
+ [CreateBatchPrediction](https://docs.aws.amazon.com/machine-learning/latest/APIReference/API_CreateBatchPrediction.html)
+ [CreateDataSourceFromRDS](https://docs.aws.amazon.com/machine-learning/latest/APIReference/API_CreateDataSourceFromRDS.html)
+ [CreateDataSourceFromRedshift](https://docs.aws.amazon.com/machine-learning/latest/APIReference/API_CreateDataSourceFromRedshift.html)
+ [CreateDataSourceFromS3](https://docs.aws.amazon.com/machine-learning/latest/APIReference/API_CreateDataSourceFromS3.html)
+ [CreateEvaluation](https://docs.aws.amazon.com/machine-learning/latest/APIReference/API_CreateEvaluation.html)
+ [CreateMLModel](https://docs.aws.amazon.com/machine-learning/latest/APIReference/API_CreateMLModel.html)
+ [CreateRealtimeEndpoint](https://docs.aws.amazon.com/machine-learning/latest/APIReference/API_CreateRealtimeEndpoint.html)
+ [DeleteBatchPrediction](https://docs.aws.amazon.com/machine-learning/latest/APIReference/API_DeleteBatchPrediction.html)
+ [DeleteDataSource](https://docs.aws.amazon.com/machine-learning/latest/APIReference/API_DeleteDataSource.html)
+ [DeleteEvaluation](https://docs.aws.amazon.com/machine-learning/latest/APIReference/API_DeleteEvaluation.html)
+ [DeleteMLModel](https://docs.aws.amazon.com/machine-learning/latest/APIReference/API_DeleteMLModel.html)
+ [DeleteRealtimeEndpoint](https://docs.aws.amazon.com/machine-learning/latest/APIReference/API_DeleteRealtimeEndpoint.html)
+ [DeleteTags](https://docs.aws.amazon.com/machine-learning/latest/APIReference/API_DeleteTags.html)
+ [DescribeTags](https://docs.aws.amazon.com/machine-learning/latest/APIReference/API_DescribeTags.html)
+ [UpdateBatchPrediction](https://docs.aws.amazon.com/machine-learning/latest/APIReference/API_UpdateBatchPrediction.html)
+ [UpdateDataSource](https://docs.aws.amazon.com/machine-learning/latest/APIReference/API_UpdateDataSource.html)
+ [UpdateEvaluation](https://docs.aws.amazon.com/machine-learning/latest/APIReference/API_UpdateEvaluation.html)
+ [UpdateMLModel](https://docs.aws.amazon.com/machine-learning/latest/APIReference/API_UpdateMLModel.html)

下列 Amazon ML 操作使用包含登入資料的請求參數。將這些請求傳送至 CloudTrail 之前，登入資料會替換為三個星號 ("\$1\$1\$1")：
+ [CreateDataSourceFromRDS](https://docs.aws.amazon.com/machine-learning/latest/APIReference/API_CreateDataSourceFromRDS.html)
+ [CreateDataSourceFromRedshift](https://docs.aws.amazon.com/machine-learning/latest/APIReference/API_CreateDataSourceFromRedshift.html)

使用 Amazon ML 主控台執行下列 Amazon ML 操作時，CloudTrail 日誌的 `RequestParameters`元件`ComputeStatistics`中不包含 屬性：
+ [CreateDataSourceFromRedshift](https://docs.aws.amazon.com/machine-learning/latest/APIReference/API_CreateDataSourceFromRedshift.html)
+ [CreateDataSourceFromS3](https://docs.aws.amazon.com/machine-learning/latest/APIReference/API_CreateDataSourceFromS3.html)

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

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

## 範例：Amazon ML 日誌檔案項目
<a name="understanding-service-name-entries"></a>

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

以下範例顯示的是展示 動作的 CloudTrail 日誌項目。

```
{
    "Records": [
        {
            "eventVersion": "1.03",
            "userIdentity": {
                "type": "IAMUser",
                "principalId": "EX_PRINCIPAL_ID",
                "arn": "arn:aws:iam::012345678910:user/Alice",
                "accountId": "012345678910",
                "accessKeyId": "EXAMPLE_KEY_ID",
                "userName": "Alice"
            },
            "eventTime": "2015-11-12T15:04:02Z",
            "eventSource": "machinelearning.amazonaws.com",
            "eventName": "CreateDataSourceFromS3",
            "awsRegion": "us-east-1",
            "sourceIPAddress": "127.0.0.1",
            "userAgent": "console.amazonaws.com",
            "requestParameters": {
                "data": {
                    "dataLocationS3": "s3://aml-sample-data/banking-batch.csv",
                    "dataSchema": "{\"version\":\"1.0\",\"rowId\":null,\"rowWeight\":null,
                        \"targetAttributeName\":null,\"dataFormat\":\"CSV\",
                        \"dataFileContainsHeader\":false,\"attributes\":[
                          {\"attributeName\":\"age\",\"attributeType\":\"NUMERIC\"},
                          {\"attributeName\":\"job\",\"attributeType\":\"CATEGORICAL\"},
                          {\"attributeName\":\"marital\",\"attributeType\":\"CATEGORICAL\"},
                          {\"attributeName\":\"education\",\"attributeType\":\"CATEGORICAL\"},
                          {\"attributeName\":\"default\",\"attributeType\":\"CATEGORICAL\"},
                          {\"attributeName\":\"housing\",\"attributeType\":\"CATEGORICAL\"},
                          {\"attributeName\":\"loan\",\"attributeType\":\"CATEGORICAL\"},
                          {\"attributeName\":\"contact\",\"attributeType\":\"CATEGORICAL\"},
                          {\"attributeName\":\"month\",\"attributeType\":\"CATEGORICAL\"},
                          {\"attributeName\":\"day_of_week\",\"attributeType\":\"CATEGORICAL\"},
                          {\"attributeName\":\"duration\",\"attributeType\":\"NUMERIC\"},
                          {\"attributeName\":\"campaign\",\"attributeType\":\"NUMERIC\"},
                          {\"attributeName\":\"pdays\",\"attributeType\":\"NUMERIC\"},
                          {\"attributeName\":\"previous\",\"attributeType\":\"NUMERIC\"},
                          {\"attributeName\":\"poutcome\",\"attributeType\":\"CATEGORICAL\"},
                          {\"attributeName\":\"emp_var_rate\",\"attributeType\":\"NUMERIC\"},
                          {\"attributeName\":\"cons_price_idx\",\"attributeType\":\"NUMERIC\"},
                          {\"attributeName\":\"cons_conf_idx\",\"attributeType\":\"NUMERIC\"},
                          {\"attributeName\":\"euribor3m\",\"attributeType\":\"NUMERIC\"},
                          {\"attributeName\":\"nr_employed\",\"attributeType\":\"NUMERIC\"}
                        ],\"excludedAttributeNames\":[]}"
                },
                "dataSourceId": "exampleDataSourceId",
                "dataSourceName": "Banking sample for batch prediction"
            },
            "responseElements": {
                "dataSourceId": "exampleDataSourceId"
            },
            "requestID": "9b14bc94-894e-11e5-a84d-2d2deb28fdec",
            "eventID": "f1d47f93-c708-495b-bff1-cb935a6064b2",
            "eventType": "AwsApiCall",
            "recipientAccountId": "012345678910"
        },
        {
            "eventVersion": "1.03",
            "userIdentity": {
                "type": "IAMUser",
                "principalId": "EX_PRINCIPAL_ID",
                "arn": "arn:aws:iam::012345678910:user/Alice",
                "accountId": "012345678910",
                "accessKeyId": "EXAMPLE_KEY_ID",
                "userName": "Alice"
            },
            "eventTime": "2015-11-11T15:24:05Z",
            "eventSource": "machinelearning.amazonaws.com",
            "eventName": "CreateBatchPrediction",
            "awsRegion": "us-east-1",
            "sourceIPAddress": "127.0.0.1",
            "userAgent": "console.amazonaws.com",
            "requestParameters": {
                "batchPredictionName": "Batch prediction: ML model: Banking sample",
                "batchPredictionId": "exampleBatchPredictionId",
                "batchPredictionDataSourceId": "exampleDataSourceId",
                "outputUri": "s3://EXAMPLE_BUCKET/BatchPredictionOutput/",
                "mLModelId": "exampleModelId"
            },
            "responseElements": {
                "batchPredictionId": "exampleBatchPredictionId"
            },
            "requestID": "3e18f252-8888-11e5-b6ca-c9da3c0f3955",
            "eventID": "db27a771-7a2e-4e9d-bfa0-59deee9d936d",
            "eventType": "AwsApiCall",
            "recipientAccountId": "012345678910"
        }
    ]
}
```