

# 适用于 Amazon EKS 的采用 OpenTelemetry 指标的 Container Insights
<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 Observability 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\$1cpu\$1utilization） | 开源原生（例如 container\$1cpu\$1usage\$1seconds\$1total） | 
| 每个指标的标签数量 | 每个指标 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/)、[Host](https://opentelemetry.io/docs/specs/semconv/resource/host/) 和 [Cloud](https://opentelemetry.io/docs/specs/semconv/resource/cloud/)（例如 `k8s.pod.name`、`k8s.namespace.name`、`k8s.node.name`、`host.name` 和 `cloud.region`）的 OpenTelemetry 语义惯例附加资源属性。这些属性在所有指标源中均一致。

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 Monitor | 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 Monitor | 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 Monitor | 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 Adapter | EFA 指标 | 必须安装 [EFA 设备插件](https://github.com/aws/eks-charts/tree/master/stable/aws-efa-k8s-device-plugin)。 | 
| NVMe | NVMe SMART 指标 | - | 
| Kube State Metrics | 容器组（pod）、节点、部署、DaemonSet、StatefulSet、ReplicaSet、任务、CronJob、服务、命名空间、PersistentVolume、PersistentVolumeClaim 指标 | - | 
| Kubernetes API 服务器 | API 服务器和 etcd 指标 | - | 