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

OpenTelemetry Collector与Grafana Tempo对接失败问题求助

一步步排查你的OpenTelemetry Trace链路问题

看起来你的核心问题是OpenTelemetry Collector根本没接收到Python脚本生成的Trace数据,所以Tempo里自然查不到。咱们从链路的起点(Python脚本)到终点(Tempo)逐一排查:

1. 先修复Python脚本的OTLP Exporter配置

你的脚本里OTLPSpanExporter的配置有明显疏漏:

  • 你写的endpoint="10.120.4.111"没加端口号!OTLP gRPC协议的默认端口是4317,必须补上;而且gRPC exporter的endpoint不需要加http://前缀,直接写host:port就行。
  • 另外你注释掉的http://10.120.7.235:4317用了HTTP前缀,这是错误的——如果用的是gRPC exporter,前缀会导致连接失败;如果要走OTLP HTTP协议,得换用HTTP版本的exporter,并且端口默认是4318,还要加上路径/v1/traces。

修改后的gRPC版本脚本:

span_exporter = OTLPSpanExporter(
    endpoint="10.120.4.111:4317"  # 补上gRPC默认端口
)

如果要改用OTLP HTTP协议,脚本要调整成这样:

from opentelemetry.exporter.otlp.proto.http.trace_exporter import OTLPSpanExporter

span_exporter = OTLPSpanExporter(
    endpoint="http://10.120.4.111:4318/v1/traces"  # HTTP端口+必填路径
)

2. 确认Collector的OTLP Receiver配置

看你的Collector Helm配置,receivers.otlp.grpc是空的——虽然默认会监听4317端口,但最好明确配置,避免网络监听范围的问题:

receivers:
  otlp:
    grpc:
      endpoint: 0.0.0.0:4317  # 明确监听所有网卡的4317端口
    http:
      endpoint: 0.0.0.0:4318  # 可选,开启HTTP接收,方便测试

同时要确认Collector的Pod已经暴露了4317/4318端口,并且Python脚本所在的环境能访问到Collector的IP/域名。

3. 用正确的方式测试Collector的OTLP端点

你用curl -X POST 10.120.4.111:4317测试是错的!4317是gRPC端口,基于HTTP/2协议,curl默认用HTTP/1.1访问,所以会返回Received HTTP/0.9 when not allowed这种奇怪错误。

正确的gRPC测试方式用grpcurl:

# 先安装grpcurl,然后执行以下命令
grpcurl -plaintext 10.120.4.111:4317 list

如果返回opentelemetry.proto.collector.trace.v1.TraceService,说明gRPC服务正常运行。

如果测试HTTP端点,用curl发送模拟Trace数据:

curl -X POST http://10.120.4.111:4318/v1/traces \
  -H "Content-Type: application/json" \
  -d '{"resourceSpans":[{"resource":{"attributes":[{"key":"service.name","value":{"stringValue":"test-service"}}]},"scopeSpans":[{"scope":{"name":"test-scope"},"spans":[{"traceId":"abc123","spanId":"def456","name":"test-span","kind":"SPAN_KIND_INTERNAL","startTimeUnixNano":1633737387000000000,"endTimeUnixNano":1633737388000000000}]}]}]}'

执行后去看Collector日志,如果出现TracesExporter相关的日志,说明端点接收正常。

4. 让Collector打印Trace日志,确认是否收到数据

你的Collector日志只有Metrics,说明没收到Trace。修改logging exporter配置,让它输出Trace的详细信息:

exporters:
  logging:
    loglevel: debug
    sampling_initial: 100
    sampling_thereafter: 100

重新部署Collector后,再运行Python脚本,如果Collector收到Trace,会在日志里打印出来,这样就能确认链路是否通了。

5. 确认Collector到Tempo的连接

最后,确保Collector的OTLP exporter能正常连接Tempo:

  • 你的配置里endpoint: tempo.monitoring:4317,要确认Tempo确实监听4317端口(Tempo默认OTLP gRPC端口是4317)。
  • 可以在Collector的Pod里执行nc -zv tempo.monitoring 4317测试网络连通性,确保域名能解析、端口能访问。

按照上面的步骤逐一排查,应该能快速定位到问题所在。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.04.30 18:18:12