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::debug::verbosity: detailed
. - 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.
-
Simple local file:
./otelcorecol --config=examples/local/otel-config.yaml
-
Simple local file using the new URI format:
./otelcorecol --config=file:examples/local/otel-config.yaml
-
Config provided via an environment variable:
./otelcorecol --config=env:MY_CONFIG_IN_AN_ENVVAR
-
Merge a
otel-config.yaml
file with the content of an environment variableMY_OTHER_CONFIG
and use the merged result as the config:./otelcorecol --config=file:examples/local/otel-config.yaml --config=env:MY_OTHER_CONFIG
-
Merge a
config.yaml
file with the content of a yaml bytes configuration (overwrites theexporters::debug::verbosity
config) and use the content as the config:./otelcorecol --config=file:examples/local/otel-config.yaml --config="yaml:exporters::debug::verbosity: normal"
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 ]
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 --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
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
To set multiple values specify multiple --set flags, so --set a=b --set c=d
becomes:
a: b
c: d
Arrays can be expressed by enclosing values in []
. For example, --set "key=[a, b, c]"
translates to:
key:
- a
- b
- c
Maps can be expressed by enclosing values in {}
. For example, "--set "key={a: c}"
translates to:
key:
a: c
- Does not support setting a key that contains a dot
.
. - Does not support setting a key that contains a equal sign
=
. - 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
.
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
- debug
extensions:
- zpages
./otelcorecol validate --config=file:examples/local/otel-config.yaml