

# 在亚马逊云服务器集群上设置和配置 Prometheus 指标收集 在 Amazon ECS 集群上设置和配置 Prometheus 指标收集
<a name="ContainerInsights-Prometheus-Setup-ECS"></a>

要从 Amazon ECS 集群收集 Prometheus 指标，您可以使用 CloudWatch 代理作为收集器或使用 AWS Distro for OpenTelemetry 收集器。有关使用 AWS Distro for OpenTelemetry 收集器的信息，请参阅 [https://aws-otel.github.io/docs/getting-started/container-insights/ecs-prometheus](https://aws-otel.github.io/docs/getting-started/container-insights/ecs-prometheus)。

下面几节介绍如何使用 CloudWatch 代理作为收集器来检索 Prometheus 指标。您可以在运行 Amazon ECS 的集群上安装带有 Prometheus 监控功能的 CloudWatch 代理，还可以选择配置该代理以抓取其他目标。这些部分还提供用于设置示例工作负载的可选教程，以使用 Prometheus 监控进行测试。

Amazon ECS 上的 Container Insights 支持 Prometheus 指标的以下启动类型和网络模式组合：


| Amazon ECS 启动类型 | 支持的网络模式 | 
| --- | --- | 
| EC2 (Linux) | 网桥、主机和 awsvpc | 
| Fargate | awsvpc | 

**VPC 安全组要求**

Prometheus 工作负载的安全组的入口规则必须向 CloudWatch 代理打开 Prometheus 端口，以便通过私有 IP 抓取 Prometheus 指标。

CloudWatch 代理的安全组的出口规则必须允许 CloudWatch 代理通过私有 IP 连接到 Prometheus 工作负载的端口。

**Topics**
+ [在 Amazon ECS 集群上安装带有 Prometheus 指标收集功能的 CloudWatch 代理](ContainerInsights-Prometheus-install-ECS.md)
+ [抓取其他 Prometheus 源并导入这些指标](ContainerInsights-Prometheus-Setup-configure-ECS.md)
+ [（可选）为 Prometheus 指标测试设置示例容器化 Amazon ECS 工作负载](ContainerInsights-Prometheus-Sample-Workloads-ECS.md)