

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

# 適用於使用自有容器的 CloudWatch 指標
<a name="model-monitor-byoc-cloudwatch"></a>

在 `/opt/ml/processing/processingjobconfig.json` 檔案的 `Environment` 對應中，如果 `publish_cloudwatch_metrics` 值為 `Enabled`，容器程式碼會在此位置發出 Amazon CloudWatch 指標：`/opt/ml/output/metrics/cloudwatch`。

此檔案的結構描述緊密地以 `PutMetrics` API 為基礎。此處未指定命名空間。它預設為下列項目：
+ `For real-time endpoints: /aws/sagemaker/Endpoint/data-metrics`
+ `For batch transform jobs: /aws/sagemaker/ModelMonitoring/data-metrics`

但是，您可以指定維度。建議您至少增加以下維度：
+ 適用於即時端點的 `Endpoint` 和 `MonitoringSchedule`
+ 適用於批次轉換工作的 `MonitoringSchedule`

下列 JSON 程式碼片段顯示如何設定維度。

如果是即時端點，請參閱下列包含 `Endpoint` 和 `MonitoringSchedule` 維度的 JSON 程式碼片段：

```
{ 
    "MetricName": "", # Required
    "Timestamp": "2019-11-26T03:00:00Z", # Required
    "Dimensions" : [{"Name":"Endpoint","Value":"endpoint_0"},{"Name":"MonitoringSchedule","Value":"schedule_0"}]
    "Value": Float,
    # Either the Value or the StatisticValues field can be populated and not both.
    "StatisticValues": {
        "SampleCount": Float,
        "Sum": Float,
        "Minimum": Float,
        "Maximum": Float
    },
    "Unit": "Count", # Optional
}
```

如果是批次轉換工作，請參閱下列包含 `MonitoringSchedule` 維度的 JSON 程式碼片段：

```
{ 
    "MetricName": "", # Required
    "Timestamp": "2019-11-26T03:00:00Z", # Required
    "Dimensions" : [{"Name":"MonitoringSchedule","Value":"schedule_0"}]
    "Value": Float,
    # Either the Value or the StatisticValues field can be populated and not both.
    "StatisticValues": {
        "SampleCount": Float,
        "Sum": Float,
        "Minimum": Float,
        "Maximum": Float
    },
    "Unit": "Count", # Optional
}
```