Configuration
Collect, process and export telemetry data efficiently with
the OpenTelemetry Collector (otelcol
).
Overview
OpenTelemetry Collector serves as a vendor-agnostic implementation for handling telemetry data. This guide covers:
- Core configuration components (receivers, processors, exporters)
- Advanced configuration options
- Best practices and examples
Prerequisites
- Basic understanding of OpenTelemetry concepts
Configuration
The OpenTelemetry Collector uses YAML for its configuration. The configuration file is structured into several sections:
receivers
OpenTelemetry receivers serve as data ingestion points for the collector, accepting telemetry data from multiple sources. They support various protocols and formats for collecting logs, metrics and traces.
receivers:
otlp:
protocols:
grpc:
endpoint: 0.0.0.0:4317
http:
endpoint: 0.0.0.0:4318
prometheus:
config:
scrape_configs:
- job_name: 'otel-collector'
scrape_interval: 10s
static_configs:
- targets: [ '0.0.0.0:8888' ]
Key features of receivers:
- Protocol support: OTLP, Prometheus, Jaeger, Zipkin
- Multiple transport options: gRPC, HTTP, TCP
- Configurable endpoints and TLS settings
- Custom metadata handling
Reference
Official Receivers Documentation
processors
Processors are applied to the data between reception and export. They can perform various transformations, filtering, and enrichment operations.
processors:
batch:
timeout: 1s
send_batch_size: 1024
memory_limiter:
check_interval: 1s
limit_mib: 4000
resourcedetection:
detectors: [ env, system ]
timeout: 5s
attributes:
actions:
- key: environment
value: production
action: insert
Common processors include:
batch
: Groups data before sending to exportersmemory_limiter
: Prevents out-of-memory errorsresourcedetection
: Detects resource informationattributes
: Modifies, adds, or removes attributes from the telemetry data
Reference
Official Processors Documentation
exporters
OpenTelemetry exporters transmit telemetry data to destination backends. They handle the delivery of logs, metrics and traces to various observability platforms and monitoring systems.
exporters:
otlp:
endpoint: otelcol:4317
tls:
insecure: true
prometheus:
endpoint: 0.0.0.0:8889
logging:
verbosity: detailed
zipkin:
endpoint: http://zipkin:9411/api/v2/spans
Supported export destinations:
- Other OpenTelemetry Collectors e.g. OpenTelemetry protocol (OTLP) endpoints
- Backend observability platforms
- Monitoring systems e.g. Prometheus systems
- Logging platforms
- Tracing systems
Reference
Official Exporters Documentation
extensions
OpenTelemetry Collector extensions enhance core functionality by providing operational features such as:
- Health monitoring and readiness checks
- Performance profiling and debugging
- Service discovery mechanisms
- Diagnostic tools and dashboards
extensions:
health_check:
endpoint: 0.0.0.0:13133
pprof:
endpoint: 0.0.0.0:1888
zpages:
endpoint: 0.0.0.0:55679
Common OpenTelemetry extensions include:
health_check
: HTTP endpoint for monitoring collector health and readiness statuspprof
: Performance profiling endpoints for debugging and optimizationzpages
: Zero-configuration diagnostic web pages for troubleshooting
Reference
Official Extensions Documentation
service
The OpenTelemetry Collector service configuration defines pipeline architecture, data flow, and operational settings such as:
- Pipeline definitions for logs, metrics and traces
- Component enablement and connections
- Collector telemetry settings
service:
extensions: [ health_check, pprof, zpages ]
pipelines:
traces:
receivers: [ otlp ]
processors: [ batch, memory_limiter ]
exporters: [ otlp, zipkin ]
metrics:
receivers: [ otlp, prometheus ]
processors: [ batch, memory_limiter ]
exporters: [ otlp, prometheus ]
logs:
receivers: [ otlp ]
processors: [ batch ]
exporters: [ otlp, logging ]
telemetry:
logs:
level: info
metrics:
level: detailed
Key components:
extensions
: Configure and enable operational extensions like health checks, profiling, and diagnosticspipelines
: Define data processing workflows for different telemetry typestelemetry
: Configuration for the collector's self-monitoring capabilities
Reference
Official Service Documentation
Advanced Configuration Elements
connectors
Connectors function as both exporters and receivers, allowing telemetry data to be routed between pipelines internally without leaving the collector.
- Cross-pipeline data routing
- Span-to-metrics conversion
- Internal data transformation
connectors:
forward:
spanmetrics:
dimensions:
- name: http.method
- name: http.status_code
metrics_flush_interval: 15s
Common OpenTelemetry connector types include:
forward
: Internal pipeline connector for routing telemetry data between processing chainsspanmetrics
: Generates performance metrics from trace spans for latency analysiscount
: Creates count metrics from spans or logsservicegraph
: Builds service dependency graphs from trace data
Reference
Official Connectors Documentation
telemetry
The OpenTelemetry Collector telemetry configuration manages the collector's self-monitoring capabilities, including:
- Internal metrics collection and reporting
- Diagnostic log management
- Trace sampling configuration
- Performance monitoring endpoints
- Health status reporting
service:
telemetry:
logs:
level: info
development: false
encoding: console
metrics:
level: detailed
address: 0.0.0.0:8888
Telemetry configuration options include:
- Log verbosity and format
- Internal metrics reporting
- Self-monitoring capabilities
Official Telemetry Documentation
Configuration Best Practices
-
Start Simple: Begin with minimal configuration and add components as needed
-
Use Environment Variables: Leverage environment variable substitution for dynamic configuration
exporters:
otlp:
endpoint: ${OTLP_ENDPOINT} -
Implement Memory Protection: Always include memory_limiter processor to prevent OOM issues
-
Consider Resources: Set appropriate resource limits based on expected load
-
Enable Health Checks: Include health_check extension for monitoring
-
Use Batching: Implement batching for efficient data transmission
OpenTelemetry Collector Configuration Best Practices
Essential configuration guidelines for optimal OpenTelemetry Collector deployment:
- Start Simple:
- Begin with basic OpenTelemetry configuration
- Add components incrementally
- Test each configuration change
- Validate telemetry flow
- Use Environment Variables:
-
Implement dynamic configuration
-
Secure sensitive information
-
Enable deployment flexibility
exporters:
otlp:
endpoint: ${OTLP_ENDPOINT}
- Implement Memory Protection:
- Configure
memory_limiter
processor - Prevent out-of-memory (OOM) crashes
- Set appropriate memory thresholds
- Monitor memory usage
- Resource Management:
- Configure CPU limits
- Set memory boundaries
- Adjust based on telemetry volume
- Monitor resource utilization
- Health Monitoring:
- Enable
health_check
extension - Configure monitoring endpoints
- Set up alerting
- Monitor collector status
- Performance Optimization:
- Enable batch processing
- Configure optimal batch sizes
- Set appropriate timeouts
- Monitor throughput metrics
Configuration Examples
Basic Collection and Export
receivers:
otlp:
protocols:
grpc:
endpoint: 0.0.0.0:4317
http:
endpoint: 0.0.0.0:4318
processors:
batch:
timeout: 1s
send_batch_size: 1024
exporters:
otlp:
endpoint: backend.example.com:4317
tls:
ca_file: /certs/ca.pem
service:
pipelines:
traces:
receivers: [ otlp ]
processors: [ batch ]
exporters: [ otlp ]
metrics:
receivers: [ otlp ]
processors: [ batch ]
exporters: [ otlp ]
logs:
receivers: [ otlp ]
processors: [ batch ]
exporters: [ otlp ]
Advanced Configuration with Multiple Pipelines
receivers:
otlp:
protocols:
grpc:
endpoint: 0.0.0.0:4317
prometheus:
config:
scrape_configs:
- job_name: 'app-metrics'
scrape_interval: 10s
static_configs:
- targets: [ 'app:8080' ]
processors:
batch:
timeout: 5s
attributes:
actions:
- key: environment
value: production
action: insert
resourcedetection:
detectors: [ env, system ]
exporters:
otlp/traces:
endpoint: traces.backend.com:4317
otlp/metrics:
endpoint: metrics.backend.com:4317
prometheus:
endpoint: 0.0.0.0:8889
extensions:
health_check:
endpoint: 0.0.0.0:13133
service:
extensions: [ health_check ]
pipelines:
traces:
receivers: [ otlp ]
processors: [ batch, attributes, resourcedetection ]
exporters: [ otlp/traces ]
metrics:
receivers: [ otlp, prometheus ]
processors: [ batch, resourcedetection ]
exporters: [ otlp/metrics, prometheus ]