Configuration

概述

参考:

顶层字段

  • receivers(map[STRING]receivers) # 配置 Receivers 组件
  • processors(map[STRING]processors) # 配置 Processors 组件
  • exporters(map[STRING]exporters) # 配置 Exporters 组件
  • extensions(map[STRING]extensions) # 配置 扩展
  • connectors # TODO
  • service(service) # 配置在处理各类可观测数据时,使用哪些扩展、使用哪些组件

otelcol/config.go 可以看到顶层字段的 struct

// Config defines the configuration for the various elements of collector or agent.
type Config struct {
	// Receivers is a map of ComponentID to Receivers.
	Receivers map[component.ID]component.Config `mapstructure:"receivers"`

	// Exporters is a map of ComponentID to Exporters.
	Exporters map[component.ID]component.Config `mapstructure:"exporters"`

	// Processors is a map of ComponentID to Processors.
	Processors map[component.ID]component.Config `mapstructure:"processors"`

	// Connectors is a map of ComponentID to connectors.
	Connectors map[component.ID]component.Config `mapstructure:"connectors"`

	// Extensions is a map of ComponentID to extensions.
	Extensions map[component.ID]component.Config `mapstructure:"extensions"`

	Service service.Config `mapstructure:"service"`
}

Notes: 这些 STRING 用来表示组件 ID。在 component/identifiable.go 和 文档中 可以看到,定义组件 ID 遵循 type[/name] 格式,e.g. otlp 或 otlp/2。只要 ID 是唯一的,就可以多次定义给定类型的组件。例如:

receivers:
  otlp:
    protocols:
      grpc:
        endpoint: 0.0.0.0:4317
      http:
        endpoint: 0.0.0.0:4318
  otlp/2:
    protocols:
      grpc:
        endpoint: 0.0.0.0:55690

processors:
  batch:
  batch/test:

exporters:
  otlp:
    endpoint: otelcol:4317
  otlp/2:
    endpoint: otelcol2:4317

extensions:
  health_check:
  pprof:
  zpages:

service:
  extensions: [health_check, pprof, zpages]
  pipelines:
    traces:
      receivers: [otlp]
      processors: [batch]
      exporters: [otlp]
    traces/2:
      receivers: [otlp/2]
      processors: [batch/test]
      exporters: [otlp/2]
    metrics:
      receivers: [otlp]
      processors: [batch]
      exporters: [otlp]
    logs:
      receivers: [otlp]
      processors: [batch]
      exporters: [otlp]

type 可用的字符串可以参考 Collector Component,像下图,在 opentelemetry-collector、opentelemetry-contrib 项目中,在对应的组件目录下,每个目录都是一个可用的 type,目录名的前缀就是 type 的名称,比如 otlpreceiver 是 OTLP Receiver,prometheusreveiver 是 Prometheus Receiver,以此类推。

image.png

receivers

processors

exporters

connectors

service


最后修改 November 6, 2024: chroot, sftp, openssh, rsyslog (34cf7d30)