

本文属于机器翻译版本。若本译文内容与英语原文存在差异，则一律以英文原文为准。

# 导出指标
<a name="metrics"></a>

**重要**  
终止支持通知：2026 年 9 月 30 日， AWS 将停止对的支持。 AWS App Mesh 2026 年 9 月 30 日之后，您将无法再访问 AWS App Mesh 控制台或 AWS App Mesh 资源。有关更多信息，请访问此博客文章[从迁移 AWS App Mesh 到 Amazon ECS Service Connect](https://aws.amazon.com/blogs/containers/migrating-from-aws-app-mesh-to-amazon-ecs-service-connect)。

Envoy 会发布许多关于其自身操作以及入站和出站流量的各个维度的统计数据。要了解有关 Envoy 统计信息的更多信息，请参阅 Envoy 文档中的[统计信息](https://www.envoyproxy.io/docs/envoy/latest/intro/arch_overview/observability/statistics)。这些指标可通过代理管理端口上的 `/stats` 端点获得，通常是 `9901`。

`stat` 前缀会有所不同，具体取决于您使用的是单个侦听器还是多个侦听器。以下提供了一些例子来说明其中的区别。

**警告**  
如果您将单个侦听器更新为多侦听器功能，由于更新了下表所示的统计前缀，您可能会面临重大变化。  
 我们建议您使用 Envoy 镜像 `1.22.2.1-prod` 或更高版本。这使您可以在 Prometheus 端点中看到类似的指标名称。


| 单侦听器 (SL)/带有“ingress”侦听器前缀的现有统计信息 | 多侦听器 (ML)/带有“ingress.<protocol>.<port>”侦听器前缀的新统计信息 | 
| --- | --- | 
|  `http.*ingress*.rds.rds_ingress_http_5555.version_text`  |  `http.*ingress.http.5555*.rds.rds_ingress_http_5555.version_text` `http.*ingress.http.6666*.rds.rds_ingress_http_6666.version_text`  | 
|  `listener.0.0.0.0_15000.http.*ingress*.downstream_rq_2xx`  |  `listener.0.0.0.0_15000.http.*ingress.http.5555*.downstream_rq_2xx` `listener.0.0.0.0_15000.http.*ingress.http.6666*.downstream_rq_2xx`  | 
|  `http.*ingress*.downstream_cx_length_ms`  |  `http.*ingress.http.5555*.downstream_cx_length_ms` `http.*ingress.http.6666*.downstream_cx_length_ms`  | 

有关统计信息端点的更多信息，请参阅 Envoy 文档中的[统计端点](https://www.envoyproxy.io/docs/envoy/latest/operations/admin#get--stats)。有关管理界面的更多信息，请参阅 [启用 Envoy 代理管理界面](troubleshooting-best-practices.md#ts-bp-enable-proxy-admin-interface)。

## 使用 Amazon EKS 的 App Mesh 的 Prometheus for App Mesh
<a name="prometheus"></a>

**重要**  
终止支持通知：2026 年 9 月 30 日， AWS 将停止对的支持。 AWS App Mesh 2026 年 9 月 30 日之后，您将无法再访问 AWS App Mesh 控制台或 AWS App Mesh 资源。有关更多信息，请访问此博客文章[从迁移 AWS App Mesh 到 Amazon ECS Service Connect](https://aws.amazon.com/blogs/containers/migrating-from-aws-app-mesh-to-amazon-ecs-service-connect)。

Prometheus 是一个开源监控和警报工具包。它的一项功能是指定一种发布指标的格式，供其他系统使用。有关 Prometheus 的更多信息，请参阅 Prometheus 文档中的[概述](https://prometheus.io/docs/introduction/overview/)。Envoy 可以通过其统计端点传入参数 `/stats?format=prometheus` 来发布其指标。

对于使用 Envoy image build v1.22.2.1-prod 的客户，还有两个额外的维度可以指示入口侦听器的特定统计数据：
+ `appmesh.listener_protocol`
+ `appmesh.listener_port`

以下是 Prometheus 现有统计数据与新统计数据的比较。
+ 带有“ingress”侦听器前缀的现有统计信息

  ```
  envoy_http_downstream_rq_xx{appmesh_mesh="multiple-listeners-mesh",appmesh_virtual_node="foodteller-vn",envoy_response_code_class="2",envoy_http_conn_manager_prefix="ingress"} 931433
  ```
+ 带有“ingress.<protocol>.<port>”的新统计数据 \$1 Appmesh Envoy Image v1.22.2.1-prod 或更高版本

  ```
  envoy_http_downstream_rq_xx{appmesh_mesh="multiple-listeners-mesh",appmesh_virtual_node="foodteller-vn",envoy_response_code_class="2",appmesh_listener_protocol="http",appmesh_listener_port="5555",envoy_http_conn_manager_prefix="ingress"} 20
  ```
+ 带有“ingress.<protocol>.<port>”的新统计数据 \$1 自定义 Envoy Imagebuil

  ```
  envoy_http_http_5555_downstream_rq_xx{appmesh_mesh="multiple-listeners-mesh",appmesh_virtual_node="foodteller-vn",envoy_response_code_class="2",envoy_http_conn_manager_prefix="ingress"} 15983
  ```

对于多个侦听器，`cds_ingress_<mesh name>_<virtual gateway name>_self_redirect_<ingress_listener_port>_<protocol>_<port>` 特殊集群是针对特定侦听器的。
+ 带有“ingress”侦听器前缀的现有统计信息

  ```
  envoy_cluster_assignment_stale{appmesh_mesh="multiple-listeners-mesh",appmesh_virtual_gateway="tellergateway-vg",Mesh="multiple-listeners-mesh",VirtualGateway="tellergateway-vg",envoy_cluster_name="cds_ingress_multiple-listeners-mesh_tellergateway-vg_self_redirect_http_15001"} 0
  ```
+ 带有“ingress.<protocol>.<port>”的新统计数据

  ```
  envoy_cluster_assignment_stale{appmesh_mesh="multiple-listeners-mesh",appmesh_virtual_gateway="tellergateway-vg",envoy_cluster_name="cds_ingress_multiple-listeners-mesh_tellergateway-vg_self_redirect_1111_http_15001"} 0
  envoy_cluster_assignment_stale{appmesh_mesh="multiple-listeners-mesh",appmesh_virtual_gateway="tellergateway-vg",envoy_cluster_name="cds_ingress_multiple-listeners-mesh_tellergateway-vg_self_redirect_2222_http_15001"} 0
  ```

### 安装 Prometheus
<a name="installing-prometheus"></a>

1. 将 EKS 存储库添加到 Helm：

   ```
   helm repo add eks https://aws.github.io/eks-charts
   ```

1. 安装 App Mesh Prometheus

   ```
   helm upgrade -i appmesh-prometheus eks/appmesh-prometheus \
   --namespace appmesh-system
   ```

### Prometheus 示例
<a name="prometheus-sample"></a>

以下是为 Prometheus 永久存储 `PersistentVolumeClaim` 创建的示例。

```
helm upgrade -i appmesh-prometheus eks/appmesh-prometheus \
--namespace appmesh-system \
--set retention=12h \
--set persistentVolumeClaim.claimName=prometheus
```

### 使用 Prometheus 的演练
<a name="prometheus-walkthrough"></a>
+ [带有 EKS 的 App Mesh — 可观测性：Prometheus](https://github.com/aws/aws-app-mesh-examples/blob/main/walkthroughs/eks/o11y-prometheus.md)

### 要通过亚马逊 EKS 进一步了解 Prometheus 和 Prometheus
<a name="prometheus-eks"></a>
+ [Prometheus 文档](https://prometheus.io/docs/introduction/overview/)
+ **EKS — ** [Prometheus 的控制面板指标](https://docs.aws.amazon.com/eks/latest/userguide/prometheus.html)

## CloudWatch 适用于 App Mesh
<a name="cloudwatch"></a>

**重要**  
终止支持通知：2026 年 9 月 30 日， AWS 将停止对的支持。 AWS App Mesh 2026 年 9 月 30 日之后，您将无法再访问 AWS App Mesh 控制台或 AWS App Mesh 资源。有关更多信息，请访问此博客文章[从迁移 AWS App Mesh 到 Amazon ECS Service Connect](https://aws.amazon.com/blogs/containers/migrating-from-aws-app-mesh-to-amazon-ecs-service-connect)。

**CloudWatch 从 Amazon EKS 向发送特使统计数据**  
您可以将 CloudWatch 代理安装到您的集群中，然后将其配置为从代理中收集指标的子集。如果你还没有 Amazon EKS 集群，则可以按照[演练：开启 Amazon EKS 的 App Mesh](https://github.com/aws/aws-app-mesh-examples/tree/main/walkthroughs/eks) 中的步骤创建一个集群。 GitHub您可以按照相同的演练将示例应用程序安装到集群上。

要为您的集群设置适当的 IAM 权限并安装代理，请按照使用 [Prometheus 指标集安装 CloudWatch 代理中的步骤进行](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/ContainerInsights-Prometheus-Setup.html)操作。默认安装包含 Prometheus 抓取配置，该配置会提取有用的 Envoy 统计数据子集。有关更多信息，请参阅[ App Mesh 的 Prometheus 指标](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/ContainerInsights-Prometheus-metrics.html#ContainerInsights-Prometheus-metrics-appmesh)。

要创建配置为显示代理正在收集的指标的 App Mesh 自定义 CloudWatch 控制面板，请按照[查看您的 Prometheus](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/ContainerInsights-Prometheus-viewmetrics.html) 指标教程中的步骤进行操作。当流量进入 App Mesh 应用程序时，您的图表将开始填充相应的指标。

### 筛选指标 CloudWatch
<a name="filtering-metrics"></a>

App Mesh [指标扩展](https://docs.aws.amazon.com/app-mesh/latest/userguide/metrics.html#metrics-extension)提供了一部分有用的指标，可让您深入了解您在网格中定义的资源的行为。由于 CloudWatch代理支持抓取 Prometheus 指标，因此您可以提供抓取配置来选择要从 Envoy 中提取并发送到的指标。 CloudWatch

[您可以在我们的指标扩展演练中找到使用 Prometheus 抓取指标的示例。](https://github.com/aws/aws-app-mesh-examples/tree/main/walkthroughs/howto-metrics-extension-ecs)

### CloudWatch 示例
<a name="cloudwatch-sample"></a>

您可以在我们的AWS 示例[存储库 CloudWatch ](https://github.com/aws-samples/aws-app-mesh-cloudwatch-agent)中找到的示例配置。

### 使用攻略 CloudWatch
<a name="cloudwatch-walkthrough"></a>
+ 在我们的 [App Mesh 研讨会](https://www.appmeshworkshop.com/introduction/)中[添加监控和日志记录功能](https://www.appmeshworkshop.com/monitoring/)。
+ [带有 EKS 的 App Mesh — 可观察性： CloudWatch](https://github.com/aws/aws-app-mesh-examples/blob/main/walkthroughs/eks/o11y-cloudwatch.md)
+ [在 ECS 上使用 App Mesh 的指标扩展](https://github.com/aws/aws-app-mesh-examples/tree/main/walkthroughs/howto-metrics-extension-ecs)

## App Mesh 的指标扩展
<a name="metrics-extension"></a>

**重要**  
终止支持通知：2026 年 9 月 30 日， AWS 将停止对的支持。 AWS App Mesh 2026 年 9 月 30 日之后，您将无法再访问 AWS App Mesh 控制台或 AWS App Mesh 资源。有关更多信息，请访问此博客文章[从迁移 AWS App Mesh 到 Amazon ECS Service Connect](https://aws.amazon.com/blogs/containers/migrating-from-aws-app-mesh-to-amazon-ecs-service-connect)。

Envoy 生成了数百个指标，细分为几个不同的维度。这些指标在与 App Mesh 的关联方面并不简单。就虚拟服务而言，没有机制可以确定哪个虚拟服务正在与给定的虚拟节点或虚拟网关通信。

App Mesh 指标扩展增强了在您的网格中运行的 Envoy 代理。此增强功能允许代理发出其他指标，以了解您定义的资源。这小部分额外指标将有助于您更加深入地了解您在 App Mesh 中定义的那些资源的行为。

要启用 App Mesh 指标扩展，请将环境变量 `APPMESH_METRIC_EXTENSION_VERSION` 设置为 `1`。

```
APPMESH_METRIC_EXTENSION_VERSION=1
```

有关 Envoy 环境变量配置的更多信息，请参阅 [Envoy 配置变量](envoy-config.md)。

### 与入站流量相关的指标
<a name="inbound-metrics"></a>
+ `ActiveConnectionCount`
  + `envoy.appmesh.ActiveConnectionCount`— 活动的 TCP 连接数。
  + *尺寸*-网格、 VirtualNode、 VirtualGateway
+ **`NewConnectionCount`**
  + `envoy.appmesh.NewConnectionCount`— TCP 连接的总数。
  + *尺寸*-网格、 VirtualNode、 VirtualGateway
+ **`ProcessedBytes`**
  + `envoy.appmesh.ProcessedBytes`— 向下游客户端发送和接收的 TCP 字节总数。
  + *尺寸*-网格、 VirtualNode、 VirtualGateway
+ **`RequestCount`**
  + `envoy.appmesh.RequestCount` — 处理的 HTTP 的请求数。
  + *尺寸*-网格、 VirtualNode、 VirtualGateway
+ **`GrpcRequestCount`**
  + `envoy.appmesh.GrpcRequestCount` — 处理的 gPRC 请求数。
  + *尺寸*-网格、 VirtualNode、 VirtualGateway

### 与出站流量相关的指标
<a name="outbound-metrics"></a>

根据出站指标是来自虚拟节点还是虚拟网关，您将在出站指标上看到不同的维度。
+ `TargetProcessedBytes`
  + `envoy.appmesh.TargetProcessedBytes`— 向 Envoy 上游目标发送和接收的 TCP 字节总数。
  + 

    *维度*：
    + 虚拟节点维度-网格、 VirtualNode、 TargetVirtualService、 TargetVirtualNode
    + 虚拟网关维度-网格、 VirtualGateway、 TargetVirtualService、 TargetVirtualNode
+ **`HTTPCode_Target_2XX_Count`**
  + `envoy.appmesh.HTTPCode_Target_2XX_Count` — 向 Envoy 上游目标发出的导致 2xx HTTP 响应的 HTTP 请求数量。
  + 

    *维度*：
    + 虚拟节点维度-网格、 VirtualNode、 TargetVirtualService、 TargetVirtualNode
    + 虚拟网关维度-网格、 VirtualGateway、 TargetVirtualService、 TargetVirtualNode
+ **`HTTPCode_Target_3XX_Count`**
  + `envoy.appmesh.HTTPCode_Target_3XX_Count` — 向 Envoy 上游目标发出的导致 3xx HTTP 响应的 HTTP 请求数量。
  + 

    *维度*：
    + 虚拟节点维度-网格、 VirtualNode、 TargetVirtualService、 TargetVirtualNode
    + 虚拟网关维度-网格、 VirtualGateway、 TargetVirtualService、 TargetVirtualNode
+ **`HTTPCode_Target_4XX_Count`**
  + `envoy.appmesh.HTTPCode_Target_4XX_Count` — 向 Envoy 上游目标发出的导致 4xx HTTP 响应的 HTTP 请求数量。
  + 

    *维度*：
    + 虚拟节点维度-网格、 VirtualNode、 TargetVirtualService、 TargetVirtualNode
    + 虚拟网关维度-网格、 VirtualGateway、 TargetVirtualService、 TargetVirtualNode
+ **`HTTPCode_Target_5XX_Count`**
  + `envoy.appmesh.HTTPCode_Target_5XX_Count` — 向 Envoy 上游目标发出的导致 5xx HTTP 响应的 HTTP 请求数量。
  + 

    *维度*：
    + 虚拟节点维度-网格、 VirtualNode、 TargetVirtualService、 TargetVirtualNode
    + 虚拟网关维度-网格、 VirtualGateway、 TargetVirtualService、 TargetVirtualNode
+ **`RequestCountPerTarget`**
  + `envoy.appmesh.RequestCountPerTarget` — 发送到 Envoy 上游目标的请求数量。
  + 

    *维度*：
    + 虚拟节点维度-网格、 VirtualNode、 TargetVirtualService、 TargetVirtualNode
    + 虚拟网关维度-网格、 VirtualGateway、 TargetVirtualService、 TargetVirtualNode
+ **`TargetResponseTime`**
  + `envoy.appmesh.TargetResponseTime` — 从向 Envoy 上游的目标发出请求到收到完整响应所经过的时间。
  + 

    *维度*：
    + 虚拟节点维度-网格、 VirtualNode、 TargetVirtualService、 TargetVirtualNode
    + 虚拟网关维度-网格、 VirtualGateway、 TargetVirtualService、 TargetVirtualNode

## 适用于 App Mesh 的 Datadog
<a name="datadog"></a>

**重要**  
终止支持通知：2026 年 9 月 30 日， AWS 将停止对的支持。 AWS App Mesh 2026 年 9 月 30 日之后，您将无法再访问 AWS App Mesh 控制台或 AWS App Mesh 资源。有关更多信息，请访问此博客文章[从迁移 AWS App Mesh 到 Amazon ECS Service Connect](https://aws.amazon.com/blogs/containers/migrating-from-aws-app-mesh-to-amazon-ecs-service-connect)。

Datadog 是一款监控和安全应用程序，用于云应用程序的端到端监控、指标和日志记录。Datadog 使您的基础架构、应用程序和第三方应用程序完全可被观察。

### 正在安装 Datadog
<a name="installing-datadog"></a>
+ EKS — 要使用 EKS 设置 Datadog，请按照 [Datadog 文档](https://docs.datadoghq.com/integrations/amazon_app_mesh/?tab=eks)中的以下步骤操作。
+ ECS EC2 — 要使用 ECS EC2 设置 Datadog，请按照 [Datadog 文档](https://docs.datadoghq.com/integrations/amazon_app_mesh/?tab=ecsec2)中的以下步骤操作。

### 要了解有关 Datadog 的更多信息
<a name="datadog-learn-more"></a>
+ [Datadog 文档](https://docs.datadoghq.com/)