> ## Documentation Index
> Fetch the complete documentation index at: https://mw-docs.middleware.io/llms.txt
> Use this file to discover all available pages before exploring further.

# OpenTelemetry Collector Contrib

> OTel Collector Contrib - Setup & Installation Docs | Middleware

The following document describes how to natively configure the OpenTelemetry Collector Contrib distribution with the Middleware platform.

Use the OpenTelemetry Collector Contrib to build your own custom distributions with the [OpenTelemetry Collector Builder](https://opentelemetry.io/docs/collector/custom-collector/), send host data without using the Middleware Host Agent, or send host data from a technology that doesnt have a native Middleware Integration.

<Note> The Kubernetes OpenTelemetry Collector Contrib distribution is not available and in development. </Note>

# Linux Installation

### Step 1: Install DEB or RPM

[Download](https://opentelemetry.io/docs/collector/installation/#linux) the `opentelemetry-collector` with the same package manager you used to install the MW Agent.

### Step 2: Use `otelcol-contrib`

Use the `otelcol-contrib (opentelemetry-collector-contrib)` distribution instead of the `otelcol (opentelemetry-collector)` for the OpenTelemetry Collector.

When prompted to download `otelcol`, download one of the following instead:

<CodeGroup>
  ```powershell DEB theme={null}
  # AMD64
  otelcol-contrib_0.92.0_linux_amd64.deb
  # ARM64
  otelcol-contrib_0.92.0_linux_arm64.deb
  ```

  ```powershell RPM theme={null}
  # AMD64
  otelcol-contrib_0.92.0_linux_amd64.rpm 
  # ARM64
  otelcol-contrib_0.92.0_linux_arm64.rpm
  ```
</CodeGroup>

### Step 3: Follow OTel Config

Once you have installed Linux, proceed to the [Configuration Section](/open-telemetry/otel-collector#configuration).

# Docker Installation

### Step 1: Install DockerHub or `ghcr.io`

[Download](https://opentelemetry.io/docs/collector/installation/) the opentelemetry-collector with the same container registry you used to install the MW Agent.

### Step 2: Use `otelcol-contrib`

Ensure the container image refers to the `opentelemetry-collector-contrib` and not core `opentelemetry-collector`.

Check your container image with the following commands:

```Shell Shell theme={null}
otelcol --version
# and
opentelemetry-collector-contrib --version
```

### Step 3: Follow OTel Config

Once you have installed Docker, proceed to the [Configuration Section](/open-telemetry/otel-collector#configuration).

# Configuration

### Step 1: Configure Collector

Follow the [OTel Configuration Instructions](https://opentelemetry.io/docs/collector/configuration/) to configure the `opentelemetry-collector-contrib`

<Note> You must fully configure the OTel Collector before adding more code to the `processors`, `exporters` and `service` section. </Note>

### Step 2: Add to Processors

Add the following code to the `processors` section:

```YAML YAML theme={null}
processors:
  resourcedetection:
    detectors: [ env, system ]
    timeout: 2s
    system:
      hostname_sources: [ os ]
  resource/middleware:
    attributes:
    - action: upsert
      key: mw.account_key
      value: <your-mw-api-key>
    - action: upsert
      from_attribute: host.name
      key: host.id
```

### Step 3: Add to Exporters

Add the following code to the `exporters` section:

```YAML YAML theme={null}
exporters:
  otlp/middleware:
    endpoint: "your-endpoint.middleware.io:443"
    headers:
      authorization: "<your-mw-api-key>"
    sending_queue:
      enabled: true
      num_consumers: 100
      queue_size: 10000
```

### Step 4: Add to Service

Add the following code within the pipelines section:

```YAML YAML theme={null}
service:
  pipelines:
    traces:
      receivers: [ <your-receivers-list-for-traces> ]
      processors: [ resourcedetection, resource/middleware, 
                    <your-processor-list-for-traces> ]
      exporters: [ otlp/middleware, <your-exporters-list-for-traces> ]
    metrics:
      receivers: [ <your-receivers-list-for-metrics> ]
      processors: [ resourcedetection, resource/middleware ]
      exporters: [ otlp/middleware, <your-exporters-list-for-metrics> ]
    logs:
      receivers: [ <your-receivers-list-for-logs> ]
      processors: [ resourcedetection, resource/middleware, 
                    <your-processors-list-for-logs> ]
      exporters: [otlp/middleware, <your-exporters-list-for-logs>]
```

# Limitations

Metrics such as bandwidth and disk speed are not currently collected by the OpenTelemetry Collector and will contain `0` in those fields. This will impact the Infrastructure page as well as any custom dashboard containing these metrics.

<Note> Need assistance or want to learn more about Middleware? Contact us at support\[at]middleware.io. </Note>
