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

OpenTelemetry Collector日志HTTP配置失效,请求协助排查

OTEL日志导出至Loki失败排查

问题现象

指标与追踪可正常收集,但日志导出失败,报错如下:

grpc@v1.68.1/clientconn.go:1384 [core] [Channel #4 SubChannel #5]grpc: addrConn.createTransport failed to connect to {Addr: "loki:3100", ServerName: "loki:3100", }. Err: connection error: desc = "error reading server preface: http2: frame too large"   {"grpc_log": true}

配置信息

1. 服务端环境变量

- OTEL_LOGS_EXPORTER=otlp
- OTEL_EXPORTER_OTLP_LOGS_PROTOCOL=http/protobuf
- OTEL_EXPORTER_OTLP_LOGS_ENDPOINT=http://collector:4318/v1/logs

2. Collector配置

receivers:
  otlp:
    protocols:
      http:
        endpoint: collector:4318  
      grpc:
        endpoint: collector:4319  
  prometheus:
    config:
      scrape_configs:
        - job_name: "b2c-service-metric-otel"
          scrape_interval: 5s
          metrics_path: "/actuator/prometheus"
          static_configs:
            - targets:
                - "b2c-service:8081"

processors:
  batch:
    timeout: 30s

exporters:
  debug:
    verbosity: detailed
  otlp/tempo:
    endpoint: tempo:4317 
    compression: "gzip"
    tls:
      insecure: true 
  otlp/loki:
    #endpoint: loki:3100 
    endpoint: loki:3100 
    #endpoint: "grpc://loki:3100"  
    compression: "gzip"
    tls:
      insecure: true

service:
  pipelines:
    metrics: 
      receivers: [ otlp ]  
      processors: [ batch ]
      exporters: [ debug ]  
    traces:
      receivers: [otlp]
      processors: [batch]
      exporters: [otlp/tempo, debug]
    logs:
      receivers: [otlp]
      processors: [batch]
      exporters: [otlp/loki, debug]

问题原因

报错显示Collector尝试通过gRPC协议连接Loki的3100端口,但Loki的3100端口默认是HTTP协议监听端口,不支持gRPC通信,导致连接失败。

OTEL的otlp exporter默认使用gRPC协议,你仅在服务端指定了日志用HTTP/protobuf协议,但Collector的otlp/loki exporter未明确指定协议,因此默认走gRPC,与Loki的端口不匹配。

解决方案

修改Collector的otlp/loki exporter配置,明确指定使用HTTP/protobuf协议,并配置正确的Loki OTLP HTTP端点:

exporters:
  otlp/loki:
    endpoint: http://loki:3100/otlp/v1/logs
    protocol: http/protobuf
    compression: "gzip"
    tls:
      insecure: true

说明:

  • protocol: http/protobuf 强制指定使用HTTP协议传输日志
  • endpoint 改为Loki官方标准的OTLP HTTP端点(旧版本Loki可能为/v1/logs,可根据实际版本调整)

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.15 07:03:16