The OpenTelemetry collector facilitates vendor-agnostic telemetry data collection, processing, and exporting. It lets you use one agent to collect and forward multiple types of telemetry in a variety of formats instead of running, operating, and maintaining several agents.
The collector improves scalability and flexibility, supporting various open source observability data formats, including Jaeger, Fluent Bit, and Prometheus. It can send information to one or more monitoring and distributed tracing back-ends, including open-source and commercial tools. Additionally, it provides a local collector agent as a default location for instrumentation libraries to export telemetry data.
In this article
The OpenTelemetry collector is in charge of collecting, processing, and exporting collected telemetry data. It is vendor-agnostic and provides capabilities for cost reduction and easy management. Some key capabilities of the OpenTelemetry collector are:
The OpenTelemetry collector has a modular architecture that allows it to ingest, collect, transform and export a variety of telemetry formats.
Image Source: Opentelemetry
The Collector is made up of the following components:
The receiver enters data into the collector. There are two types of receivers: push-based and pull-based. A receiver typically receives data in a specified format, converts it to an internal format, and passes it to processors and exporters defined in the OpenTelemetry pipeline. Traces and metrics can have a receiver-specific format.
Processors are used to process data before sending it to export. They can transform metrics and rename spans. They also support batching data before sending, retrying if an export fails, adding metadata, and performing tail-based sampling.
Exporters can export data to several open source and commercial back-ends. For example, a console exporter makes it possible to export log data to console output, while a file export can dump data to a file.
The preceding three components—receivers, processors, and exporters—make up the Open Telemetry Pipeline, which define how telemetry data is collected and handled.
In addition to pipeline components, there are two other components that assist in data handling and communication.
Extensions are optional, and provide additional functionality not supported by the default collector. They do not need direct access to telemetry data. Three extensions provided by OpenTelemetry are health_check, pprof, and zpages (learn more in the documentation). You can also create your own extensions.
Services are used to enable components within receivers, processors, exports, and extensions. The service section of the configuration consists of two subsections: extensions and pipes.
Related content: Read our guide to OpenTelemetry architecture
The OpenTelemetry Collector offers one binary and two deployment options:
There are two Collector versions available from the OpenTelemetry project:
Kubernetes can deploy agents as daemon sets and or one gateway instance:
$ kubectl apply -f https://raw.githubusercontent.com/open-telemetry/opentelemetry-collector/main/examples/k8s/otel-config.yaml
This example above can provide the starting point for extending and customizing before use in a live production environment.
You can also use the OpenTelemetry Operator to configure and maintain OpenTelemetry Collector instances using automatic upgrade management, OpenTelemetry configuration-based service configuration, and automatic sidecar insertion into a deployment.
All Collector releases include RPM and DEB packaging for Linux amd64 and arm64 systems. This packaging contains the default configuration retained at /etc/otelcol/config.yaml after installation.
Windows packages its releases as .tar.gz (gzipped tarballs). You need to unpack them using a tool that supports this format.
All Collector versions include an executable otelcol.exe that you can run after unpacking.
You can build the latest version of the Collector based on your local operating system, enable all receivers when running the binary, and export any data received locally to a file. The Collector sends all data to a container, scraping its Prometheus metrics. The following example illustrates the Collector using two terminal windows. Run the following script in the first terminal window:
$ git clone https://github.com/open-telemetry/opentelemetry-collector.git
$ cd opentelemetry-collector
$ make install-tools
$ make otelcorecol
$ ./bin/otelcorecol_* --config ./examples/local/otel-config.yaml
You can test your new Collector in the second terminal window using the following script:
$ git clone https://github.com/open-telemetry/opentelemetry-collector-contrib.git
$ cd opentelemetry-collector-contrib/examples/demo/server
$ go build -o main main.go; ./main & pid1="$!"
$ cd ../client
$ go build -o main main.go; ./main
You can stop the client using the Ctrl-c command. Stop the server using the kill $pid1 command. You can also stop the Collector using the Ctrl-c command in the relevant terminal window.
There are four main ways you can check the health of the Collector and investigate issues: logs, metrics, local exporters, and health checks.
Collector logs are the first place you should look to identify and resolve issues. The default log verbosity level is INFO—you can change this as needed.
To define the log level, set the service::telemetry::logs property:
service:
telemetry:
logs:
level: "debug"
The OpenTelemetry Container automatically exposes Prometheus metrics on port 8888 using the path /metrics. In a containerized environment, it makes sense to expose this port as a public interface to ensure you can troubleshoot even if not connected directly to the relevant host.
You can customize the port using the service::telemetry::metrics property:
service:
telemetry:
metrics:
address: ":8888"
If necessary, you can define a local exporter to inspect data being processed by the Collector. For example, here is how to use the file exporter, to confirm that data is being correctly received and processed:
receivers:
otlp:
http:
grpc:
exporters:
file:
path: spans.json
service:
pipelines:
traces:
receivers: [otlp]
processors: []
exporters: [file]
The OpenTelemetry Collector provides the health_check extension, which is available by default on port 13133 when OpenTelemetry is installed. You can use health checks to identify if a Collector is working. Here is how to enable a health check:
extensions:
health_check:
service:
extensions: [health_check]
The response should look like this:
{
"status": "Server available",
"upSince": "2022-04-28T05:33:87.8769865Z",
"uptime": "22.3139965s"
}
Lumigo is a cloud native observability tool, purpose-built to navigate the complexities of microservices. Through automated distributed tracing, Lumigo is able to stitch together the distributed components of an application in one complete view, and track every service of every request.
Taking an agentless approach to monitoring, Lumigo sees through the black boxes of third parties, APIs and managed services.
With Lumigo users can:
Get started with a free trial of Lumigo for your microservice applications.