如何给open telemetry collector添加持久化

背景

一般的配置,open telemetry collector的处理都是在内存里的,collector收到数据后返回给客户端说处理成功,但是其实是在内存中,如果 collector 重启, 就会丢失数据.
对于一些不能接受数据丢失的场景旧需要给open telemetry collector添加持久化

open telemetry collector contrib添加了存储扩展,我们此处可以使用它的file_storage扩展

介绍

示例配置如下,针对不同的级别的服务,设置不同的策略,重要的服务设置持久化存储

extensions:
  file_storage:
    directory: /var/lib/otelcol/storage
    timeout: 10s
    compaction:
      enabled: true
      directory: /var/lib/otelcol/compaction

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

processors:
  batch:
    timeout: 10s
  routing:
    from_attribute: "service_level"
    default_exporters: [otlp/normal]
    table:
      - value: "high"
        exporters: [otlp/critical]

exporters:
  otlp/critical:
    endpoint: "backend:4317"
    sending_queue:
      enabled: true
      num_consumers: 20
      queue_size: 10000
      storage: file_storage

  otlp/normal:
    endpoint: "backend:4317"
    sending_queue:
      enabled: true
      num_consumers: 5
      queue_size: 2000

service:
  extensions: [file_storage]
  pipelines:
    traces:
      receivers: [otlp]
      processors: [routing, batch]
      exporters: [otlp/critical, otlp/normal]
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容