service

package
v0.79.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 5, 2023 License: Apache-2.0 Imports: 47 Imported by: 55

README

OpenTelemetry Collector Service

How to provide configuration?

The --config flag accepts either a file path or values in the form of a config URI "<scheme>:<opaque_data>". Currently, the OpenTelemetry Collector supports the following providers scheme:

  • file - Reads configuration from a file. E.g. file:path/to/config.yaml.
  • env - Reads configuration from an environment variable. E.g. env:MY_CONFIG_IN_AN_ENVVAR.
  • yaml - Reads configuration from yaml bytes. E.g. yaml:exporters::logging::loglevel: debug.
  • http - Reads configuration from a HTTP URI. E.g. http://www.example.com

For more technical details about how configuration is resolved you can read the configuration resolving design.

Single Config Source
  1. Simple local file:

    ./otelcorecol --config=examples/local/otel-config.yaml

  2. Simple local file using the new URI format:

    ./otelcorecol --config=file:examples/local/otel-config.yaml

  3. Config provided via an environment variable:

    ./otelcorecol --config=env:MY_CONFIG_IN_AN_ENVVAR

Multiple Config Sources
  1. Merge a otel-config.yaml file with the content of an environment variable MY_OTHER_CONFIG and use the merged result as the config:

    ./otelcorecol --config=file:examples/local/otel-config.yaml --config=env:MY_OTHER_CONFIG

  2. Merge a config.yaml file with the content of a yaml bytes configuration (overwrites the exporters::logging::loglevel config) and use the content as the config:

    ./otelcorecol --config=file:examples/local/otel-config.yaml --config="yaml:exporters::logging::loglevel: info"

Embedding other configuration providers

One configuration provider can also make references to other config providers, like the following:

receivers:
  otlp:
    protocols:
      grpc:

exporters: ${file:otlp-exporter.yaml}

service:
  extensions: [ ]
  pipelines:
    traces:
      receivers:  [ otlp ]
      processors: [  ]
      exporters:  [ otlp ]

How to override config properties?

The --set flag allows to set arbitrary config property. The --set values are merged into the final configuration after all the sources specified by the --config are resolved and merged.

The Format and Limitations of --set
Simple property

The --set option takes always one key/value pair, and it is used like this: --set key=value. The YAML equivalent of that is:

key: value
Complex nested keys

Use dot (.) in the pair's name as key separator to reference nested map values. For example, --set outer.inner=value is translated into this:

outer:
  inner: value
Multiple values

To set multiple values specify multiple --set flags, so --set a=b --set c=d becomes:

a: b
c: d
Array values

Arrays can be expressed by enclosing values in []. For example, --set "key=[a, b, c]" translates to:

key:
  - a
  - b
  - c
Map values

Maps can be expressed by enclosing values in {}. For example, "--set "key={a: c}" translates to:

key:
  a: c
Limitations
  1. Does not support setting a key that contains a dot ..
  2. Does not support setting a key that contains a equal sign =.
  3. The configuration key separator inside the value part of the property is "::". For example --set "name={a::b: c}" is equivalent with --set name.a.b=c.

How to check components available in a distribution

Use the sub command build-info. Below is an example:

   ./otelcorecol components

Sample output:

buildinfo:
   command: otelcorecol
   description: Local OpenTelemetry Collector binary, testing only.
   version: 0.62.1-dev
receivers:
   - otlp
processors:
   - memory_limiter
   - batch
exporters:
   - otlp
   - otlphttp
   - logging
extensions:
   - zpages
   - memory_ballast

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config added in v0.52.0

type Config struct {
	// Telemetry is the configuration for collector's own telemetry.
	Telemetry telemetry.Config `mapstructure:"telemetry"`

	// Extensions are the ordered list of extensions configured for the service.
	Extensions []component.ID `mapstructure:"extensions"`

	// Pipelines are the set of data pipelines configured for the service.
	Pipelines map[component.ID]*PipelineConfig `mapstructure:"pipelines"`
}

Config defines the configurable components of the Service.

func (*Config) Validate added in v0.64.0

func (cfg *Config) Validate() error

type PipelineConfig added in v0.68.0

type PipelineConfig struct {
	Receivers  []component.ID `mapstructure:"receivers"`
	Processors []component.ID `mapstructure:"processors"`
	Exporters  []component.ID `mapstructure:"exporters"`
}

PipelineConfig defines the configuration of a Pipeline.

func (*PipelineConfig) Validate added in v0.68.0

func (cfg *PipelineConfig) Validate() error

type Service added in v0.68.0

type Service struct {
	// contains filtered or unexported fields
}

Service represents the implementation of a component.Host.

func New

func New(ctx context.Context, set Settings, cfg Config) (*Service, error)

func (*Service) Logger added in v0.68.0

func (srv *Service) Logger() *zap.Logger

Logger returns the logger created for this service. This is a temporary API that may be removed soon after investigating how the collector should record different events.

func (*Service) Shutdown added in v0.68.0

func (srv *Service) Shutdown(ctx context.Context) error

func (*Service) Start added in v0.68.0

func (srv *Service) Start(ctx context.Context) error

Start starts the extensions and pipelines. If Start fails Shutdown should be called to ensure a clean state.

type Settings added in v0.68.0

type Settings struct {
	// BuildInfo provides collector start information.
	BuildInfo component.BuildInfo

	// Receivers builder for receivers.
	Receivers *receiver.Builder

	// Processors builder for processors.
	Processors *processor.Builder

	// Exporters builder for exporters.
	Exporters *exporter.Builder

	// Connectors builder for connectors.
	Connectors *connector.Builder

	// Extensions builder for extensions.
	Extensions *extension.Builder

	// AsyncErrorChannel is the channel that is used to report fatal errors.
	AsyncErrorChannel chan error

	// LoggingOptions provides a way to change behavior of zap logging.
	LoggingOptions []zap.Option
	// contains filtered or unexported fields
}

Settings holds configuration for building a new service.

Directories

Path Synopsis
internal
fanoutconsumer
Package fanoutconsumer contains implementations of Traces/Metrics/Logs consumers that fan out the data to multiple other consumers.
Package fanoutconsumer contains implementations of Traces/Metrics/Logs consumers that fan out the data to multiple other consumers.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL