MENU

链路跟踪与观测:OpenTelemetry 组件搭建

October 17, 2023 • 学习

收集组件搭建

Collector

  • Docker
#!/bin/bash
file_path=`readlink -f $0`
dir_path=`dirname $file_path`
version=0.87.0

# !! 请注意,0.87.0版本已不再支持Jaeger格式导出
sudo docker run \
    -v $dir_path/config.yaml:/etc/otelcol-contrib/config.yaml \
    -p 1888:1888 \
    -p 8888:8888 \
    -p 8889:8889 \
    -p 13133:13133 \
    -p 4317:4317 \
    -p 4318:4318 \
    -p 55679:55679 \
    otel/opentelemetry-collector-contrib:$version

# 1888:pprof extension
# 8888:Prometheus metrics exposed by the collector
# 8889:Prometheus exporter metrics
# 13133:health_check extension
# 4317:OTLP gRPC receiver
# 4318:OTLP http receiver
# 55679:zpages extension
receivers:
  otlp: # the OTLP receiver the app is sending traces to
    protocols:
      http:

processors:
  memory_limiter:
    check_interval: 1s
    limit_mib: 2000
  batch:

exporters:
  logging:
    loglevel: debug
  prometheusremotewrite: # the PRW exporter, to ingest metrics to backend
    endpoint: http://1.220.68.72:9201/api/v1/write
  elasticsearch/trace:
    endpoints: [http://elk.example.com:9200]
    traces_index: trace_index
    api_key: *******==
    tls:
      insecure: true

  otlp/elastic: 
    endpoint: "fleet-otel-server.example.com:8200"
    headers:
      Authorization: "Bearer ********"

service:
  pipelines:
    traces/dev:
      receivers: [otlp]
      processors: [memory_limiter, batch]
      exporters: [logging, otlp/elastic]
    metrics/dev:
      receivers: [otlp]
      processors: [memory_limiter, batch]
      exporters: [logging, otlp/elastic]
    logs/dev:
      receivers: [otlp]
      processors: [memory_limiter, batch]
      exporters: [logging, otlp/elastic]
Archives QR Code
QR Code for this page
Tipping QR Code