Integrating with OpenTelemetry by using the OpenTelemetry Collector
The OpenTelemetry Collector is one of the most popular OpenTelemetry tools that offers a vendor-agnostic implementation for receiving, processing, and exporting telemetry data.
By using the OpenTelemetry Collector, you can set resource attributes or forward the OpenTelemetry data to an Instana agent or Instana backend.
- OpenTelemetry Collector
- Setting resource attributes with the OpenTelemetry Collector
- Scenarios for using the OpenTelemetry Collector with Instana
OpenTelemetry Collector
The OpenTelemetry official distributions include OpenTelemetry Collector (otelcol) and OpenTelemetry Collector Contrib (otelcol-contrib), which are available as part of the OpenTelemetry Collector releases repository.
The OpenTelemetry Collector is the core component of the OpenTelemetry ecosystem, offering vendor-independent function for telemetry data collection, processing, and export. To explore its capabilities, download the latest executable binary files from GitHub releases.
The OpenTelemetry Collector Contrib extends the core collector with extra components and community-contributed enhancements, providing specialized functionalities for advanced use cases. While some of the components in this repository are part of the otelcol distribution, but most of the components here are only available as part of the otelcol-contrib distribution. You can build your own custom distributions with the OpenTelemetry Collector builder by using the components that you need from the core repository, the contrib repository, and third-party or internal repositories. To use these enhancements for your telemetry data collection needs, download the latest executable binary files from OpenTelemetry Collector releases.
Moreover, OpenTelemetry Collector releases are available as container image binary files that ensure ease of deployment across various environments.
For more information about installation instructions for the OpenTelemetry Collector, see Install the Collector.
Setting resource attributes with the OpenTelemetry Collector
You can set resource attributes with the OpenTelemetry Collector. For more information, see Using the OpenTelemetry Collector to set resource attributes.
Scenarios for using the OpenTelemetry Collector with Instana
OpenTelemetry data can be directly transmitted to either an Instana agent or the Instana backend, given their compatibility with both OTLP/gRPC
and OTLP/HTTP
protocols.
The OpenTelemetry Collector comprises the following essential components:
- Receiver: Collects telemetry data from various sources and converts it into a standardized format for processing.
- Processor: Modifies and enhances telemetry data, allowing for tasks such as filtering, aggregation, and attribute addition.
- Exporter: Sends processed telemetry data to external destinations in the required format, facilitating integration with observability platforms and other tools.
The OpenTelemetry Collector offers significant enhancements in data processing, manipulation, and debugging capabilities, while also enabling the configuration of multiple data export destinations. Therefore, using the OTLP endpoint of an Instana
agent or backend to configure either the otlp
exporter or otlphttp
exporter within the OpenTelemetry Collector ensures that data handling is efficient and streamlined.
While the OpenTelemetry Collector Contrib includes a specific Instana exporter, using a standard OTLP exporter is preferred due to its adherence to standards and its comprehensive support for all OpenTelemetry data signals, including traces, metrics, and logs.
The following examples show how the OpenTelemetry Collector configuration enhances the Telemetry data process:
- The
batch
processor can be used to improve data process efficiency. - The
spanmetrics
processor can be used to extract golden signal metrics from spans.
For the batch
processor, see the following sample configuration that is based on performance considerations for most scenarios:
processors:
batch:
send_batch_size: 5000
send_batch_max_size: 10000
...
service:
pipelines:
traces:
receivers: [...]
processors: [..., batch]
exporters: [...]
metrics:
receivers: [...]
processors: [..., batch]
exporters: [...]
For the spanmetrics
processor, see the following sample configuration.
Most of metrics that are derived from Instana-related services are based on spans. In most cases, incorporating the spanmetrics
processor into the pipeline for exporting metrics to Instana is unnecessary.
processors:
spanmetrics:
metrics_exporter: otlp/1
...
pipelines:
traces:
receivers: [...]
processors: [...]
exporters: [...]
metrics:
receivers: [...]
processors: [...]
exporters: [..., otlp/1]
The following example shows a typical configuration for debugging data by using the OpenTelemetry Collector:
exporters:
logging:
verbosity: detailed
...
pipelines:
traces:
receivers: [...]
processors: [...]
exporters: [..., logging]
metrics:
receivers: [...]
processors: [...]
exporters: [..., logging]
Forward Telemetry data to an Instana agent with the OpenTelemetry Collector
To enable OTLP ports for an Instana agent, add the following snippet to the configuration.yaml file of your Instana host agent. Ensure to save the changes, and restart the Instana host agent to apply the modifications.
com.instana.plugin.opentelemetry:
grpc:
enabled: true
http:
enabled: true
By default, the Instana agent is configured to listen on the localhost IP address (127.0.0.1). The following snippet shows a typical example configuration for the OpenTelemetry Collector to forward telemetry data to a local Instana host agent
by using the OTLP/gRPC
protocol.
exporters:
otlp:
endpoint: "localhost:4317"
tls:
insecure: true
...
service:
pipelines:
traces:
receivers: [...]
processors: [...]
exporters: [..., otlp]
metrics:
receivers: [...]
processors: [...]
exporters: [..., otlp]
logs:
receivers: [...]
processors: [...]
exporters: [..., otlp]
The following example shows a typical configuration of the OpenTelemetry Collector for forwarding Telemetry data to a local Instana host agent with the OTLP/HTTP
protocol.
exporters:
otlphttp:
endpoint: "localhost:4318"
tls:
insecure: true
...
service:
pipelines:
traces:
receivers: [...]
processors: [...]
exporters: [..., otlphttp]
metrics:
receivers: [...]
processors: [...]
exporters: [..., otlphttp]
logs:
receivers: [...]
processors: [...]
exporters: [..., otlphttp]
Forward Telemetry data to the Instana backend with the OpenTelemetry Collector
To forward OpenTelemetry data to the Instana backend by using the OpenTelemetry Collector, follow these steps:
-
Identify your Instana deployment region. The endpoint for the Instana backend varies based on the region. To find the Instana region that is dedicated to your environment, click More > About Instana in the Instana UI. In the Instana dialog, you can see the Instana deployment region.
Each Instana SaaS environment is associated with a specific region name, such as
blue
,red
,green
,orange
, orcoral
. For detailed information about the endpoint of the Instana backendotlp-acceptor
, see Endpoints of Instana backend otlp-acceptor. -
Configure an
OTLP/gRPC
orOTLP/HTTP
connection to the Instana backend. For example, if you are using the Instanablue
environment, you can configure anOTLP/gRPC
orOTLP/HTTP
connection to the Instana backend by using the following configuration:-
OTLP/gRPC
exporters: otlp: endpoint: otlp-blue-saas.instana.io:4317 headers: x-instana-key: xxxx ... service: pipelines: traces: receivers: [...] processors: [...] exporters: [..., otlp] metrics: receivers: [...] processors: [...] exporters: [..., otlp] logs: receivers: [...] processors: [...] exporters: [..., otlp]
Set the x-instana-key field with the agent key of the Instana agent for targeting the Instana backend.
-
OTLP/HTTP
exporters: otlphttp: endpoint: "otlp-blue-saas.instana.io:4318" headers: x-instana-key: xxxx ... service: pipelines: traces: receivers: [...] processors: [...] exporters: [..., otlphttp] metrics: receivers: [...] processors: [...] exporters: [..., otlphttp] logs: receivers: [...] processors: [...] exporters: [..., otlphttp]
-
Instana backend requires host.id or a similar attribute
The Instana backend requires a host.id
, faas.id
, or device.id
resource attribute. Alternatively, you can set x-instana-host
as an environment variable.
If the OpenTelemetry Collector is deployed in a DaemonSet mode (that is, the OpenTelemetry Collector is located in the same host of the applications that send out the OpenTelemetry data), you can also set the x-instana-host
header by using the OTLP exporter. See the following example:
exporters:
otlp:
endpoint: otlp-blue-saas.instana.io:4317
headers:
x-instana-key: xxxxxxx
x-instana-host: xxxx
You must specify the host ID in the x-instana-host field if no host.id
, faas.id
, or device.id
resource attribute is defined in your application or system.
Another way to add the host.id
resource attribute is to use the resource
processor:
processors:
resource:
attributes:
- key: host.id
action: upsert
value: "myhost1.ibm.com"
After you complete all configuration changes in the agent configuration.yaml
file, run the following command to use the OpenTelemetry Collector:
otel-contrib --config configuration.yaml