

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

# 容器合約輸入
<a name="model-monitor-byoc-contract-inputs"></a>

Amazon SageMaker Model Monitor 平台根據指定的排程，調用您的容器程式碼。如果您選擇撰寫自己的容器程式碼，下列環境變數可使用。在此情況下，您可以分析目前資料集或評估限制條件 (如果選擇如此)，並發出指標 (如果適用)。

即時端點和批次轉換工作的可用環境變數相同，`dataset_format` 變數除外。如果您使用的是即時端點，`dataset_format` 變數會支援下列選項：

```
{\"sagemakerCaptureJson\": {\"captureIndexNames\": [\"endpointInput\",\"endpointOutput\"]}}
```

如果您使用的是批次轉換工作，則 `dataset_format` 支援下列選項：

```
{\"csv\": {\"header\": [\"true\",\"false\"]}}
```

```
{\"json\": {\"line\": [\"true\",\"false\"]}}
```

```
{\"parquet\": {}}
```

下列程式碼範例顯示可用於容器程式碼的完整環境變數集 (並使用即時端點的 `dataset_format` 格式)。

```
"Environment": {
 "dataset_format": "{\"sagemakerCaptureJson\": {\"captureIndexNames\": [\"endpointInput\",\"endpointOutput\"]}}",
 "dataset_source": "/opt/ml/processing/endpointdata",
 "end_time": "2019-12-01T16: 20: 00Z",
 "output_path": "/opt/ml/processing/resultdata",
 "publish_cloudwatch_metrics": "Disabled",
 "sagemaker_endpoint_name": "endpoint-name",
 "sagemaker_monitoring_schedule_name": "schedule-name",
 "start_time": "2019-12-01T15: 20: 00Z"
}
```

Parameters 


| 參數名稱 | Description | 
| --- | --- | 
| dataset\$1format |  對於從 `Endpoint` 支援的 `MonitoringSchedule` 開始的工作，此為 `sageMakerCaptureJson` 且擷取索引為 `endpointInput`、`endpointOutput` 或兩者兼有。對於批次轉換工作，這會指定資料格式，無論是 CSV、JSON 或 Parquet。  | 
| dataset\$1source |  如果您使用的是即時端點，可使用與 `start_time` 和 `end_time` 指定的監控期間對應的資料所在的本機路徑。在此路徑中，資料位於 ` /{endpoint-name}/{variant-name}/yyyy/mm/dd/hh` 中。 我們有時會下載超過開始和結束時間所指定的資料量。容器程式碼會依需要來剖析資料。  | 
| output\$1path |  寫入輸出報告和其他檔案的本機路徑。請在 `CreateMonitoringSchedule` 請求中以 `MonitoringOutputConfig.MonitoringOutput[0].LocalPath` 指定此參數。它會上傳到 `MonitoringOutputConfig.MonitoringOutput[0].S3Uri` 中指定的 `S3Uri` 路徑。  | 
| publish\$1cloudwatch\$1metrics |  對於由 `CreateMonitoringSchedule` 啟動的工作，此參數設定為 `Enabled`。容器可以選擇在 `[filepath]` 寫入 Amazon CloudWatch 輸出檔案。  | 
| sagemaker\$1endpoint\$1name |  如果您使用的是即時端點，則為啟動此排程工作的 `Endpoint` 名稱。  | 
| sagemaker\$1monitoring\$1schedule\$1name |  啟動此工作的 `MonitoringSchedule` 名稱。  | 
| \$1sagemaker\$1endpoint\$1datacapture\$1prefix\$1 |  如果您使用的是即時端點，則為 `Endpoint` 的 `DataCaptureConfig` 參數中指定的前置詞。如果容器需要直接存取超過 SageMaker AI 在 `dataset_source` 路徑上已下載的資料量，則可以使用此參數。  | 
| start\$1time, end\$1time |  此分析執行的時間範圍。例如，對於排定在 05:00 (UTC) 執行的工作和 2020/2/20 執行的工作，`start_time` 為 2020-02-19T06:00:00Z，`end_time` 為 2020-02-20T05:00:00Z  | 
| baseline\$1constraints: |  ` BaselineConfig.ConstraintResource.S3Uri` 中指定的基準限制條件檔案的本機路徑。這只有當 `CreateMonitoringSchedule` 請求中指定此參數時才能使用。  | 
| baseline\$1statistics |  `BaselineConfig.StatisticsResource.S3Uri` 中指定的基準統計資料檔案的本機路徑。這只有當 `CreateMonitoringSchedule` 請求中指定此參數時才能使用。  | 