You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Prometheus无法抓取EKS单Pod不同端口/路径指标的解决方案咨询

问题:AWS App Mesh架构下同时抓取EKS Pod中应用与Envoy Sidecar指标

在AWS App Mesh架构的EKS集群中,单个Pod内同时部署了Web应用和Envoy Sidecar代理,需要同时抓取两者的指标以提升监控可见性,但当前配置仅能获取其中一方的指标。

我原本期望通过类似以下(无效)的Pod注解配置实现双指标抓取:

podAnnotations: {
  prometheus.io/scrape: "true",
  prometheus.io/path1: "/metrics",
  prometheus.io/port1: "3000",
  prometheus.io/path2: "/stats/prometheus",
  prometheus.io/port2: "9901"
}

以下是当前的Prometheus抓取配置,目前仅能获取应用指标,无法抓取Envoy代理指标:

scrape_configs:
- job_name: otel-agent
  scrape_interval: 10s
  static_configs:
  - targets:
    - $${K8S_POD_IP}:8889
- job_name: 'kubernetes-pod-appmesh-envoy'
  sample_limit: 10000
  metrics_path: /stats/prometheus
  kubernetes_sd_configs:
  - role: pod
  relabel_configs:
  - action: keep
    regex: true
    source_labels:
    - __meta_kubernetes_pod_annotation_prometheus_io_scrape_envoy
  - source_labels: [__meta_kubernetes_pod_container_name]
    action: keep
    regex: '^envoy$'
  - source_labels: [__address__, __meta_kubernetes_pod_annotation_prometheus_io_port]
    action: replace
    regex: ([^:]+)(?::\d+)?;(\d+)
    replacement: ${1}:9901
    target_label: __address__
  - action: labelmap
    regex: __meta_kubernetes_pod_label_(.+)
  - action: replace
    source_labels:
    - __meta_kubernetes_namespace
    target_label: Namespace
  - source_labels: [__meta_kubernetes_pod_name]
    action: replace
    target_label: pod_name
  - action: replace
    source_labels:
    - __meta_kubernetes_pod_container_name
    target_label: container_name
  - action: replace
    source_labels:
    - __meta_kubernetes_pod_controller_name
    target_label: pod_controller_name
  - action: replace
    source_labels:
    - __meta_kubernetes_pod_controller_kind
    target_label: pod_controller_kind
  - action: replace
    source_labels:
    - __meta_kubernetes_pod_phase
    target_label: pod_phase
- job_name: kubernetes-pods
    kubernetes_sd_configs:
    - role: pod
    relabel_configs:
    - action: keep
      regex: true
      source_labels:
      - __meta_kubernetes_pod_annotation_prometheus_io_scrape
    - source_labels: [ __address__ ]
      regex: '.*9901.*'
      action: drop
    - action: replace
      regex: (.+)
      source_labels:
      - __meta_kubernetes_pod_annotation_prometheus_io_path
      target_label: __metrics_path__
    - action: replace
      regex: ([^:]+)(?::\d+)?;(\d+)
      replacement: $1:$2
      source_labels:
      - __address__
      - __meta_kubernetes_pod_annotation_prometheus_io_port
      target_label: __address__
    - action: labelmap
      regex: __meta_kubernetes_pod_label_(.+)
    - action: replace
      source_labels:
      - __meta_kubernetes_namespace
      target_label: kubernetes_namespace
    - action: replace
      source_labels:
      - __meta_kubernetes_pod_name
      target_label: kubernetes_pod_name

Istio默认提供指标合并器,可将所有指标发布到同一端点,但AWS App Mesh暂无此功能。请问是否可以通过调整Prometheus抓取配置,在无需自定义指标合并器的前提下,同时抓取Envoy代理与Web应用的指标?

注:本问题的核心区别在于,应用与Envoy使用不同的指标端口和路径。


内容的提问来源于stack exchange,提问作者Emma Kelly

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.29 17:14:55