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

如何在Google Cloud控制台查看上报至托管Prometheus的OpenTelemetry指标?

GKE集群OpenTelemetry指标排查与验证指南

一、查找示例指标的位置

在Cloud Console中,通过以下路径定位目标指标:

  1. Metrics Explorer
    • 进入Cloud Monitoring的Metrics Explorer页面,在「指标」搜索框输入example_requests_total或example_random_numbers,注意指标可能被前缀修饰为custom.googleapis.com/opentelemetry/example_requests_total。
    • 资源类型选择优先匹配Kubernetes Pod,或根据Collector日志中检测到的k8s.cluster.name选择对应GKE集群关联资源。
  2. 指标库
    • 进入Cloud Monitoring的「指标库」页面,搜索example_前缀的指标,找到后可直接添加至Metrics Explorer查看。

二、验证部署是否正常

1. 确认示例应用指标暴露正常

在GKE控制台找到prom-example的Pod名称,执行命令:

kubectl exec <prom-example-pod-name> -- curl http://localhost:<metrics-port>/metrics

(替换<prom-example-pod-name>和<metrics-port>为实际值,示例应用默认metrics端口通常为8080)
检查输出内容是否包含example_requests_total和example_random_numbers相关指标行。

2. 确认Collector是否成功采集指标

找到otel-collector的Pod名称,执行命令:

kubectl exec <otel-collector-pod-name> -- curl http://localhost:8888/metrics

检查输出中是否存在prometheus_scrape_samples_scraped指标且数值大于0;同时查看是否有example_前缀的指标被采集。

3. 检查Collector配置正确性

查看Collector使用的ConfigMap:

kubectl get configmap <otel-collector-configmap-name> -o yaml

确认:

  • Prometheus Receiver配置中,kubernetes_sd_configs下的标签选择器是否能正确匹配prom-example服务;
  • 是否配置了googlecloud exporter,确保Collector可将指标发送至Cloud Monitoring;
  • 由于未启用Workload Identity,需确认GKE节点的服务账号拥有roles/monitoring.metricsWriter权限,否则Collector无法写入指标。

4. 补充日志排查

从现有日志看,Collector已正常启动并加载Prometheus Receiver,但缺少后续抓取日志。查看Collector完整日志:

kubectl logs <otel-collector-pod-name>

查找是否有Scraping target或Successfully scraped target条目,若缺失则说明Collector未发现prom-example的指标端点,需调整服务发现配置。

内容的提问来源于stack exchange,提问作者Vincent Adams

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.30 21:24:53