

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

# 適用於 Amazon EKS 的 Container Insights 搭配 OpenTelemetry 指標
<a name="container-insights-otel-metrics"></a>

**預覽版**  
使用 OpenTelemetry 指標的 Container Insights 可讓您了解 Amazon EKS 叢集基礎設施的運作狀態。在美國東部 （維吉尼亞北部）、美國西部 （奧勒岡）、歐洲 （愛爾蘭）、亞太區域 （新加坡） 和亞太區域 （雪梨） 可免費公開預覽。

Amazon CloudWatch Observability EKS 附加元件會從 Amazon EKS 叢集收集開放原始碼指標，並使用 OpenTelemetry Protocol (OTLP) 以 30 秒精細程度將其傳送至 CloudWatch。這些指標使用原始來源的指標名稱，包括 cAdvisor、Prometheus Node Exporter、NVIDIA DCGM、Kube State Metrics 和 AWS Neuron Monitor。您可以在 CloudWatch Query Studio 中使用 PromQL 或透過 Prometheus 相容查詢 API 來查詢這些指標。

每個指標都會自動擴充最多 150 個標籤，包括 OpenTelemetry 語意慣例屬性，以及 Kubernetes Pod 和節點標籤。PromQL 會在查詢時間處理彙總，因此每個指標會在每個資源發佈一次，而不是在多個彙總層級發佈。附加元件也會將 AWS Neuron 和 AWS Elastic Fabric Adapter 的加速器指標與使用它們的特定 Pod 和容器建立關聯，以提供無法單獨從指標來源取得的可見性。

若要在 Amazon EKS 叢集上啟用 OTel Container Insights，請透過 Amazon EKS 主控台或透過基礎設施做為程式碼安裝 Amazon CloudWatch 可觀測性 EKS 附加元件版本 `v6.0.1-eksbuild.1`或更新版本。

如需設定 OTel Container Insights 的詳細資訊，請參閱 [設定 Container Insights](deploy-container-insights.md)。

如需使用 PromQL 查詢這些指標的詳細資訊，請參閱 [PromQL 查詢](CloudWatch-PromQL-Querying.md)。

## OTel Container Insights 與 Container Insights 的比較 （增強版）
<a name="container-insights-otel-comparison"></a>

下表摘要說明 Container Insights （增強版） 和 OTel Container Insights 之間的差異。


| 功能 | Container Insights （增強版） | OTel Container Insights | 
| --- | --- | --- | 
| 指標名稱 | CloudWatch 格式指標 （例如 pod\_cpu\_utilization) | 開放原始碼原生 （例如 container\_cpu\_usage\_seconds\_total) | 
| 每個指標的標籤 | 每個指標 3–6 個預先定義的維度 | 最多 150 個標籤，包括所有 Kubernetes Pod 和節點標籤 | 
| 聚合 | 在多個層級預先彙總 （叢集、命名空間、工作負載、Pod) | 原始每個資源指標；使用 PromQL 在查詢時間彙總 | 
| 查詢語言 | CloudWatch 指標 API | PromQL (Prometheus 相容） | 
| 指標擷取 | EMF 格式的 CloudWatch Logs | OTLP 端點 | 

## 如何標記指標
<a name="container-insights-otel-labels"></a>

OTel Container Insights 收集的每個指標都包含三個來源的標籤。

遙測來源原生標籤  
來自原始指標來源的標籤 （例如，cAdvisor 提供標籤，例如 `pod`、 `namespace`和 `container`)。這些會保留為資料點屬性。

OpenTelemetry 資源屬性  
附加元件會遵循 [Kubernetes](https://opentelemetry.io/docs/specs/semconv/resource/k8s/)、[主機](https://opentelemetry.io/docs/specs/semconv/resource/host/)和[雲端](https://opentelemetry.io/docs/specs/semconv/resource/cloud/)的 OpenTelemetry 語意慣例附加資源屬性，例如 `k8s.pod.name`、`k8s.namespace.name`、`k8s.node.name`、 `host.name`和 `cloud.region`。這些屬性在所有指標來源之間都是一致的。

Kubernetes Pod 和節點標籤  
從 Kubernetes API 發現的所有 Pod 標籤和節點標籤都會附加為具有字首 `k8s.pod.label`和 的資源屬性`k8s.node.label`。

如需如何使用 PromQL 查詢這些屬性的詳細資訊，請參閱 [PromQL 查詢](CloudWatch-PromQL-Querying.md)。

## 支援的指標
<a name="container-insights-otel-supported-metrics"></a>

下表列出 OTel Container Insights 收集的指標來源和類別。


| 指標來源 | 指標類別 | 先決條件 | 
| --- | --- | --- | 
| cAdvisor | CPU 指標 | - | 
| cAdvisor | 記憶體指標 | - | 
| cAdvisor | 網路指標 | - | 
| cAdvisor | 磁碟和檔案系統指標 | - | 
| Prometheus Node Exporter | CPU 指標 | - | 
| Prometheus Node Exporter | 記憶體指標 | - | 
| Prometheus Node Exporter | 磁碟指標 | - | 
| Prometheus Node Exporter | 檔案系統指標 | - | 
| Prometheus Node Exporter | 網路指標 | - | 
| Prometheus Node Exporter | 系統指標 | - | 
| Prometheus Node Exporter | VMStat 指標 | - | 
| Prometheus Node Exporter | Netstat 和通訊端指標 | - | 
| NVIDIA DCGM | GPU 使用率和效能指標 | 必須安裝 [NVIDIA 裝置外掛程式](https://github.com/NVIDIA/k8s-device-plugin)和 [NVIDIA 容器工具組](https://github.com/NVIDIA/nvidia-container-toolkit)。 | 
| NVIDIA DCGM | GPU 記憶體指標 | 必須安裝 [NVIDIA 裝置外掛程式](https://github.com/NVIDIA/k8s-device-plugin)和 [NVIDIA 容器工具組](https://github.com/NVIDIA/nvidia-container-toolkit)。 | 
| NVIDIA DCGM | GPU 功率和熱度指標 | 必須安裝 [NVIDIA 裝置外掛程式](https://github.com/NVIDIA/k8s-device-plugin)和 [NVIDIA 容器工具組](https://github.com/NVIDIA/nvidia-container-toolkit)。 | 
| NVIDIA DCGM | GPU 限流指標 | 必須安裝 [NVIDIA 裝置外掛程式](https://github.com/NVIDIA/k8s-device-plugin)和 [NVIDIA 容器工具組](https://github.com/NVIDIA/nvidia-container-toolkit)。 | 
| NVIDIA DCGM | GPU 錯誤和可靠性指標 | 必須安裝 [NVIDIA 裝置外掛程式](https://github.com/NVIDIA/k8s-device-plugin)和 [NVIDIA 容器工具組](https://github.com/NVIDIA/nvidia-container-toolkit)。 | 
| NVIDIA DCGM | GPU NVLink 指標 | 必須安裝 [NVIDIA 裝置外掛程式](https://github.com/NVIDIA/k8s-device-plugin)和 [NVIDIA 容器工具組](https://github.com/NVIDIA/nvidia-container-toolkit)。 | 
| NVIDIA DCGM | GPU 資訊指標 | 必須安裝 [NVIDIA 裝置外掛程式](https://github.com/NVIDIA/k8s-device-plugin)和 [NVIDIA 容器工具組](https://github.com/NVIDIA/nvidia-container-toolkit)。 | 
| AWS Neuron 監視器 | NeuronCore 指標 | 必須安裝 [Neuron 驅動程式](https://awsdocs-neuron.readthedocs-hosted.com/en/latest/general/setup/neuron-setup/pytorch/neuronx/ubuntu/torch-neuronx-ubuntu22.html)和 [Neuron 裝置外掛程式](https://awsdocs-neuron.readthedocs-hosted.com/en/latest/containers/kubernetes-getting-started.html)。 | 
| AWS Neuron 監視器 | NeuronDevice 指標 | 必須安裝 [Neuron 驅動程式](https://awsdocs-neuron.readthedocs-hosted.com/en/latest/general/setup/neuron-setup/pytorch/neuronx/ubuntu/torch-neuronx-ubuntu22.html)和 [Neuron 裝置外掛程式](https://awsdocs-neuron.readthedocs-hosted.com/en/latest/containers/kubernetes-getting-started.html)。 | 
| AWS Neuron 監視器 | Neuron 系統指標 | 必須安裝 [Neuron 驅動程式](https://awsdocs-neuron.readthedocs-hosted.com/en/latest/general/setup/neuron-setup/pytorch/neuronx/ubuntu/torch-neuronx-ubuntu22.html)和 [Neuron 裝置外掛程式](https://awsdocs-neuron.readthedocs-hosted.com/en/latest/containers/kubernetes-getting-started.html)。 | 
| AWS Elastic Fabric 轉接器 | EFA 指標 | 必須安裝 [EFA 裝置外掛程式](https://github.com/aws/eks-charts/tree/master/stable/aws-efa-k8s-device-plugin)。 | 
| NVMe | NVMe SMART 指標 | - | 
| Kube 狀態指標 | Pod、節點、部署、DaemonSet、StatefulSet、ReplicaSet、Job、CronJob、Service、Namespace、PersistentVolume、PersistentVolumeClaim 指標 | - | 
| Kubernetes API 伺服器 | API 伺服器和等指標 | - | 

## 停用雙重發佈
<a name="container-insights-otel-disable-dual-publish"></a>

從 Amazon CloudWatch Observability EKS 附加元件版本 v6.0.1-eksbuild.1 或更新版本開始，附加元件預設會透過 Container Insights （舊版） 和 OTel Container Insights 發佈指標。如果只想使用其中一個，您可以停用另一個。

### 停用 OTel 容器洞見
<a name="container-insights-otel-disable-otel"></a>

若要停止發佈 OTel Container Insights 指標並僅使用舊版 Container Insights，請將`otelContainerInsights`組態設定為停用。

使用下列組態值：

```
{"otelContainerInsights":{"enabled":false}}
```

執行下列命令來套用組態：

```
aws eks update-addon \
  --cluster-name {{CLUSTER_NAME}} \
  --addon-name amazon-cloudwatch-observability \
  --configuration-values '{"otelContainerInsights":{"enabled":false}}' \
  --region {{REGION}}
```

### 停用容器洞見
<a name="container-insights-otel-disable-legacy"></a>

若要停止發佈舊版 Container Insights 指標並僅使用 OTel Container Insights，請將`containerInsights`組態設定為停用。

使用下列組態值：

```
{"containerInsights":{"enabled":false}}
```

執行下列命令來套用組態：

```
aws eks update-addon \
  --cluster-name {{CLUSTER_NAME}} \
  --addon-name amazon-cloudwatch-observability \
  --configuration-values '{"containerInsights":{"enabled":false}}' \
  --region {{REGION}}
```