Configuration
You are viewing the English version of this page because it has not yet been fully translated. Interested in helping out? See Contributing.
After installing the system packages, the
OpenTelemetry Injector
instruments supported applications and exports telemetry using OTLP to
localhost on ports 4317 (gRPC) and 4318 (HTTP) by default. This page
describes how to change where telemetry is sent and how to adjust the injected
configuration.
Set the export destination
The recommended setup is to run a local OpenTelemetry Collector on the host that receives this telemetry and forwards it to your backend.
To send telemetry somewhere else, the recommended way is to use a configuration
file. You rarely need to write one from scratch: each language package ships a
ready-to-use reference file at /etc/opentelemetry/<language>/otel-config.yaml
that wires up the exporter endpoint, headers, and service name through
environment-variable interpolation. Copy or adapt one of these files with your
declarative configuration,
then activate it by setting OTEL_CONFIG_FILE in the injector environment file
at /etc/opentelemetry/injector/default_env.conf:
OTEL_CONFIG_FILE=/etc/opentelemetry/config.yaml
For .NET, file-based configuration also requires
OTEL_EXPERIMENTAL_FILE_BASED_CONFIGURATION_ENABLED=true. Without it, the
configuration file is silently ignored.
Restart your applications for configuration changes to take effect.
Configure with environment variables
If you prefer not to use a configuration file, you can set standard
OpenTelemetry environment variables directly in the injector environment file at
/etc/opentelemetry/injector/default_env.conf. Any variable set there is
applied to every instrumented process. For example, to export directly to an
OTLP endpoint that requires an API key:
OTEL_EXPORTER_OTLP_ENDPOINT=https://otlp.example.com
OTEL_EXPORTER_OTLP_HEADERS=api-key=REPLACE_ME
Because default_env.conf uses standard OpenTelemetry environment variables,
you can configure any SDK behavior the same way, such as OTEL_SERVICE_NAME,
OTEL_RESOURCE_ATTRIBUTES, or the various sampler and exporter settings. See
SDK environment variables for the full
list.
Restart your applications for configuration changes to take effect.
Run a local Collector
Running a Collector on the host lets you keep the export
configuration of your applications simple: they send OTLP to localhost, and
the Collector handles batching, retries, and routing to one or more backends.
Install and run the Collector separately for now; it is not yet part of the base
opentelemetry metapackage.
Next steps
- Learn more about the OpenTelemetry Collector.
- Review the available SDK environment variables.
Feedback
Was this page helpful?
Thank you. Your feedback is appreciated!
Please let us know how we can improve this page. Your feedback is appreciated!