|
1 |
| -# opentelemetry-collector-builder |
2 |
| -OpenTelemetry Collector Builder |
| 1 | +# OpenTelemetry Collector builder |
| 2 | + |
| 3 | +This program generates a custom OpenTelemetry Collector binary based on a given configuration. |
| 4 | + |
| 5 | +## TL;DR |
| 6 | +```console |
| 7 | +$ go get github.com/open-telemetry/opentelemetry-collector-builder |
| 8 | +$ cat > ~/.otelcol-builder.yaml <<EOF |
| 9 | +exporters: |
| 10 | + - gomod: "github.com/open-telemetry/opentelemetry-collector-contrib/exporter/alibabacloudlogserviceexporter v0.19.0" |
| 11 | +EOF |
| 12 | +$ opentelemetry-collector-builder --output-path=/tmp/dist |
| 13 | +$ cat > /tmp/otelcol.yaml <<EOF |
| 14 | +receivers: |
| 15 | + otlp: |
| 16 | + protocols: |
| 17 | + grpc: |
| 18 | + endpoint: localhost:4317 |
| 19 | + |
| 20 | +processors: |
| 21 | + batch: |
| 22 | + |
| 23 | +exporters: |
| 24 | + logging: |
| 25 | + |
| 26 | +service: |
| 27 | + pipelines: |
| 28 | + traces: |
| 29 | + receivers: |
| 30 | + - otlp |
| 31 | + processors: |
| 32 | + - batch |
| 33 | + exporters: |
| 34 | + - logging |
| 35 | +EOF |
| 36 | +$ /tmp/dist/otelcol-custom --config=/tmp/otelcol.yaml |
| 37 | +``` |
| 38 | + |
| 39 | +## Installation |
| 40 | + |
| 41 | +Download the binary for your respective platform under the ["Releases"](https://github.com/open-telemetry/opentelemetry-collector-builder/releases/latest) page. |
| 42 | + |
| 43 | +## Running |
| 44 | + |
| 45 | +A configuration file isn't strictly required, but the final artifact won't be different than a regular OpenTelemetry Collector. You probably want to specify at least one module (extension, exporter, receiver, processor) to add to your distribution. You can specify them via a configuration file. When no `--config` flag is provided with the location for the configuration file, `${HOME}/.otelcol-builder.yaml` will be used, if available. |
| 46 | + |
| 47 | +```console |
| 48 | +$ opentelemetry-collector-builder --config config.yaml |
| 49 | +``` |
| 50 | + |
| 51 | +Use `opentelemetry-collector-builder --help` to learn about which flags are available. |
| 52 | + |
| 53 | +## Configuration |
| 54 | + |
| 55 | +The configuration file is composed of two main parts: `dist` and module types. All `dist` options can be specified via command line flags: |
| 56 | + |
| 57 | +```console |
| 58 | +$ opentelemetry-collector-builder --name="my-otelcol" |
| 59 | +``` |
| 60 | + |
| 61 | +The module types are specified at the top-level, and might be: `extensions`, `exporters`, `receivers` and `processors`. They all accept a list of components, and each component is required to have at least the `gomod` entry. When not specified, the `import` value is inferred from the `gomod`. When not specified, the `name` is inferred from the `import`. |
| 62 | + |
| 63 | +The `import` might specify a more specific path than what is specified in the `gomod`. For instance, your Go module might be `gitlab.com/myorg/myrepo` and the `import` might be `gitlab.com/myorg/myrepo/myexporter`. |
| 64 | + |
| 65 | +The `name` will typically be omitted, except when multiple components have the same name. In such case, set a unique name for each module. |
| 66 | + |
| 67 | +Optionally, a list of `go mod` replace entries can be provided, in case custom overrides are needed. This is typically necessary when a processor or some of its transitive dependencies have dependency problems. |
| 68 | + |
| 69 | +```yaml |
| 70 | +dist: |
| 71 | + module: github.com/open-telemetry/opentelemetry-collector-builder # the module name for the new distribution, following Go mod conventions. Optional, but recommended. |
| 72 | + name: otelcol-custom # the binary name. Optional. |
| 73 | + description: "Custom OpenTelemetry Collector distribution" # a long name for the application. Optional. |
| 74 | + include_core: true # whether the core components should be included in the distribution. Optional. |
| 75 | + otelcol_version: "0.19.0" # the OpenTelemetry Collector version to use as base for the distribution. Optional. |
| 76 | + output_path: /tmp/otelcol-distributionNNN # the path to write the output (sources and binary). Optional. |
| 77 | + version: "1.0.0" # the version for your custom OpenTelemetry Collector. Optional. |
| 78 | + go: "/usr/bin/go" # which Go binary to use to compile the generated sources. Optional. |
| 79 | +exporters: |
| 80 | + - gomod: "github.com/open-telemetry/opentelemetry-collector-contrib/exporter/alibabacloudlogserviceexporter v0.19.0" # the Go module for the component. Required. |
| 81 | + import: "github.com/open-telemetry/opentelemetry-collector-contrib/exporter/alibabacloudlogserviceexporter" # the import path for the component. Optional. |
| 82 | + name: "alibabacloudlogserviceexporter" # package name to use in the generated sources. Optional. |
| 83 | + path: "./alibabacloudlogserviceexporter" # in case a local version should be used for the module, the path relative to the current dir, or a full path can be specified. Optional. |
| 84 | +replaces: |
| 85 | + # a list of "replaces" directives that will be part of the resulting go.mod |
| 86 | + - github.com/open-telemetry/opentelemetry-collector-contrib/internal/common => github.com/open-telemetry/opentelemetry-collector-contrib/internal/common v0.19.0 |
| 87 | +``` |
0 commit comments