olddocs/gen_edot_col_components/templates/ocb.jinja2 (65 lines of code) (raw):

# Build a Custom EDOT-like Collector You can build and configure a [custom collector](https://opentelemetry.io/docs/collector/custom-collector/) or extend the [OpenTelemetry Collector Contrib ](https://github.com/open-telemetry/opentelemetry-collector-contrib) distribution to collect logs and metrics and send them to Elastic Observability. For a more seamless experience, use the Elastic Distribution of the OpenTelemetry Collector. Refer to the [configuration](./config/index) docs for more on configuring the EDOT Collector. ## Build a custom collector To build a custom collector to collect your telemetry data and send it to Elastic Observability, you need to: 1. Install the OpenTelemetry Collector builder (ocb). 1. Create a builder configuration file. 1. Build the collector. Refer to the following sections to complete these steps. ### Step 1. Install the OpenTelemetry Collector builder Install the ocb using the command that aligns with your system from the [OpenTelemetry building a custom collector documentation](https://opentelemetry.io/docs/collector/custom-collector/#step-1---install-the-builder). {: .warning} Make sure to install **version {{ otel_col_version }}** of the OpenTelemetry Collector Builder! ### Step 2. Create a builder configuration file Create a builder configuration file,`builder-config.yml`, to define the custom collector. This file specifies the components (extensions, exporters, processors, receivers, and connectors) included in your custom collector. The following example `builder-config.yml` file contains the components needed to send your telemetry data to Elastic Observability. For more information on these components, refer to the [components](./components) documentation. Keep or remove components from the example configuration file to fit your needs. ``` yaml dist: name: otelcol-dev description: Basic OTel Collector distribution for Developers output_path: ./otelcol-dev otelcol_version: {{ otel_col_version }} {% if grouped_components['Extensions'] -%} extensions: {%- for comp in grouped_components['Extensions'] %} - gomod: {{ comp['dep'] }} {%- endfor %} {%- endif %} {% if grouped_components['Receivers'] -%} receivers: {%- for comp in grouped_components['Receivers'] %} - gomod: {{ comp['dep'] }} {%- endfor %} {%- endif %} {% if grouped_components['Exporters'] -%} exporters: {%- for comp in grouped_components['Exporters'] %} - gomod: {{ comp['dep'] }} {%- endfor %} {%- endif %} {% if grouped_components['Processors'] -%} processors: {%- for comp in grouped_components['Processors'] %} - gomod: {{ comp['dep'] }} {%- endfor %} {%- endif %} {% if grouped_components['Connectors'] -%} connectors: {%- for comp in grouped_components['Connectors'] %} - gomod: {{ comp['dep'] }} {%- endfor %} {%- endif %} {% if grouped_components['Providers'] -%} providers: {%- for comp in grouped_components['Providers'] %} - gomod: {{ comp['dep'] }} {%- endfor %} {%- endif %} ``` ### Step 3. Build the Collector Build your custom collector using the ocb tool and the configuration file by running the following command: `builder --config builder-config.yml` This command generates a new collector in the specified output path, `otelcol-dev`. The generated collector includes the components you specified in the configuration file. For general information on building a custom collector, refer to the [OpenTelemetry documentation](https://opentelemetry.io/docs/collector/custom-collector/#step-1---install-the-builder).