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

Otel文件导入Collector后Aspire Dashboard无数据排查求助

问题背景

我此前未使用过Otel Collector,正在搭建一套系统:先将Otel遥测数据导出至文件,再把文件内容重新导入Otel Collector(基于otel/opentelemetry-collector-contrib镜像)。为方便调试,我自行构建了镜像(官方镜像太精简,不好排查问题),本质是下载并运行otel-contrib可执行文件,Dockerfile如下:

# syntax=docker/dockerfile:1.5
# Install collector
FROM MyFatUbuntuImage AS Builder

WORKDIR /App

RUN \
  curl --proto '=https' --tlsv1.2 -fOL https://github.com/open-telemetry/opentelemetry-collector-releases/releases/download/v0.118.0/otelcol-contrib_0.118.0_linux_amd64.tar.gz && \
  tar -xvf otelcol-contrib_0.118.0_linux_amd64.tar.gz && \
  rm otelcol-contrib_0.118.0_linux_amd64.tar.gz

# Final stage
FROM ubuntu

WORKDIR /App
COPY --from=Builder /App /App/

ENTRYPOINT [ "/App/otelcol-contrib", "--config", "/etc/otelcol/config.yaml" ]

遥测数据导出配置(已正常工作)

我已经成功配置Otel Collector将传入的遥测数据导出到文件,相关配置如下:

Compose项目配置

services:
  otel-exporter:
    image: opentelemetry-collector
    container_name: otel-exporter
    restart: always
    ports:
      - "1100:4317"  # OTLP gRPC
    volumes:
      - ./otel-config.yml:/etc/otelcol/config.yaml
      - ./Data:/Data

Otel Collector配置文件(otel-config.yml)

receivers:
  otlp:
    protocols:
      grpc:
        endpoint: 0.0.0.0:4317
      http:
        endpoint: 0.0.0.0:4318

processors:
  batch:

exporters:
  file:
    path: "/Data/Telemetry.json"  # 遥测数据存储路径
    rotation:
      max_megabytes: 100  # 文件达到100MB时轮转
      max_days: 7         # 文件保留7天
      max_backups: 5      # 最多保留5个轮转备份文件
  debug:

service:
  pipelines:
    traces:
      receivers: [otlp]
      processors: [batch]
      exporters: [debug, file]
    
    logs:
      receivers: [otlp]
      processors: [batch]
      exporters: [debug, file]
    
    metrics:
      receivers: [otlp]
      processors: [batch]
      exporters: [debug, file]

目前已经得到包含追踪、日志和指标的Telemetry.json文件,这部分完全正常。

遥测数据导入配置(存在问题)

问题出在导入环节,我的尝试配置如下:

Compose项目配置

services:
  aspire-dashboard:
    image: mcr.microsoft.com/dotnet/aspire-dashboard:9.0
    container_name: aspire-dashboard
    restart: unless-stopped
    ports:
      - "18888:18888"  # 仪表盘UI
      - "4317:18889"  # OTLP gRPC
    environment:
      - LOGGING__LOGLEVEL__DEFAULT=Information
      - LOGGING__LOGLEVEL__MICROSOFT=Information
      - LOGGING__LOGLEVEL__MICROSOFT.ASPNETCORE.DATAPROTECTION=Information

  otel-importer:
    #image: otel/opentelemetry-collector-contrib:latest
    image: opentelemetry-collector
    container_name: otel-importer
    restart: unless-stopped
    depends_on:
      - aspire-dashboard
    volumes:
      - "./otel-config.yml:/etc/otelcol/config.yaml:ro"
      - "./Telemetry.json:/Data/Telemetry.json"  # 挂载导出的遥测文件

Otel Collector配置文件(otel-config.yml)

receivers:
  otlpjsonfile:
    include:
      - "/Data/*"

processors:
  batch:

exporters:
  otlp:
    endpoint: "http://aspire-dashboard:18889"  # 将遥测数据发送到另一个OTLP Collector
    tls:
      insecure: true

  debug:
    verbosity: detailed

service:
  pipelines:
    traces:
      receivers: [otlpjsonfile]
      processors: [batch]
      exporters: [debug, otlp]

    logs:
      receivers: [otlpjsonfile]
      processors: [batch]
      exporters: [debug, otlp]
      
    metrics:
      receivers: [otlpjsonfile]
      processors: [batch]
      exporters: [debug, otlp]

运行后仪表盘始终为空。我开放了4317端口用于测试,之前通过该端口向Collector推送遥测数据是成功的,本次用这个Compose文件测试也能正常推送。我已经检查了权限和文件挂载情况,都没问题,但两个容器的日志都无法解释当前状况。

容器日志

导入容器(otel-importer)日志

2025-02-03T13:26:20.280Z        info    service@v0.118.0/service.go:164 Setting up own telemetry...
2025-02-03T13:26:20.280Z        info    telemetry/metrics.go:70 Serving metrics {"address": "localhost:8888", "metrics level": "Normal"}
2025-02-03T13:26:20.280Z        info    builders/builders.go:26 Development component. May change in the future.        {"kind": "exporter", "data_type": "logs", "name": "debug"}
2025-02-03T13:26:20.281Z        info    builders/builders.go:26 Development component. May change in the future.        {"kind": "exporter", "data_type": "traces", "name": "debug"}
2025-02-03T13:26:20.281Z        info    builders/builders.go:26 Development component. May change in the future.        {"kind": "exporter", "data_type": "metrics", "name": "debug"}
2025-02-03T13:26:20.281Z        info    service@v0.118.0/service.go:230 Starting otelcol-contrib...     {"Version": "0.118.0", "NumCPU": 16}
2025-02-03T13:26:20.281Z        info    extensions/extensions.go:39     Starting extensions...
2025-02-03T13:26:20.282Z        warn    grpc@v1.69.4/clientconn.go:1381 [core] [Channel #3 SubChannel #4]grpc: addrConn.createTransport failed to connect to {Addr: "aspire-dashboard:18889", ServerName: "aspire-dashboard:18889", }. Err: connection error: desc = "transport: Error while dialing: dial tcp 172.25.0.2:18889: connect: connection refused"   {"grpc_log": true}
2025-02-03T13:26:20.282Z        warn    grpc@v1.69.4/clientconn.go:1381 [core] [Channel #1 SubChannel #2]grpc: addrConn.createTransport failed to connect to {Addr: "aspire-dashboard:18889", ServerName: "aspire-dashboard:18889", }. Err: connection error: desc = "transport: Error while dialing: dial tcp 172.25.0.2:18889: connect: connection refused"   {"grpc_log": true}
2025-02-03T13:26:20.282Z        info    service@v0.118.0/service.go:253 Everything is ready. Begin running and processing data.
2025-02-03T13:26:20.282Z        warn    grpc@v1.69.4/clientconn.go:1381 [core] [Channel #5 SubChannel #6]grpc: addrConn.createTransport failed to connect to {Addr: "aspire-dashboard:18889", ServerName: "aspire-dashboard:18889", }. Err: connection error: desc = "transport: Error while dialing: dial tcp 172.25.0.2:18889: connect: connection refused"   {"grpc_log": true}
2025-02-03T13:26:20.483Z        info    fileconsumer/file.go:265        Started watching file   {"kind": "receiver", "name": "otlpjsonfile", "data_type": "metrics", "component": "fileconsumer", "path": "/Data/Telemetry.json"}
2025-02-03T13:26:20.483Z        info    fileconsumer/file.go:265        Started watching file   {"kind": "receiver", "name": "otlpjsonfile", "data_type": "traces", "component": "fileconsumer", "path": "/Data/Telemetry.json"}
2025-02-03T13:26:20.483Z        info    fileconsumer/file.go:265        Started watching file   {"kind": "receiver", "name": "otlpjsonfile", "data_type": "logs", "component": "fileconsumer", "path": "/Data/Telemetry.json"}

启动时有连接拒绝的警告,但后续看起来正常。

仪表盘容器(aspire-dashboard)日志

info: Aspire.Dashboard.DashboardWebApplication[0]
      Aspire version: 9.0.0+01ed51919f8df692ececce51048a140615dc759d
warn: Microsoft.AspNetCore.DataProtection.Repositories.FileSystemXmlRepository[60]
      Storing keys in a directory '/home/app/.aspnet/DataProtection-Keys' that may not be persisted outside of the container. Protected data will be unavailable when container is destroyed. For more information go to https://aka.ms/aspnet/dataprotectionwarning
info: Microsoft.AspNetCore.DataProtection.KeyManagement.XmlKeyManager[62]
      User profile is available. Using '/home/app/.aspnet/DataProtection-Keys' as key repository; keys will not be encrypted at rest.
info: Microsoft.AspNetCore.DataProtection.KeyManagement.XmlKeyManager[58]
      Creating key {50cd5d08-6625-41e8-a6af-6c34d194c0d4} with creation date 2025-02-03 13:43:40Z, activation date 2025-02-03 13:43:40Z, and expiration date 2025-05-04 13:43:40Z.
warn: Microsoft.AspNetCore.DataProtection.KeyManagement.XmlKeyManager[35]
      No XML encryptor configured. Key {50cd5d08-6625-41e8-a6af-6c34d194c0d4} may be persisted to storage in unencrypted form.
info: Microsoft.AspNetCore.DataProtection.Repositories.FileSystemXmlRepository[39]
      Writing data to file '/home/app/.aspnet/DataProtection-Keys/key-50cd5d08-6625-41e8-a6af-6c34d194c0d4.xml'.
info: Aspire.Dashboard.DashboardWebApplication[0]
      Now listening on: http://[::]:18888
info: Aspire.Dashboard.DashboardWebApplication[0]
      Login to the dashboard at http://localhost:18888/login?t=47b568160c0b6f6a40fbf4ba20101010. The URL may need changes depending on how network access to the container is configured.
info: Aspire.Dashboard.DashboardWebApplication[0]
      OTLP/gRPC listening on: http://[::]:18889
info: Aspire.Dashboard.DashboardWebApplication[0]
      OTLP/HTTP listening on: http://[::]:18890
warn: Aspire.Dashboard.DashboardWebApplication[0]
      OTLP server is unsecured. Untrusted apps can send telemetry to the dashboard. For more information, visit https://go.microsoft.com/fwlink/?linkid=2267030

此处无错误。

疑问

请问我哪里操作有误?


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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.14 14:52:32