From b585b0edd6cc5dfd9a0a133f7c274ca8ebdc3e8d Mon Sep 17 00:00:00 2001 From: Jose Riguera Date: Thu, 22 Aug 2024 17:40:04 +0200 Subject: [PATCH] Add support for binary otelcollectors --- README.md | 2 +- .../addon-add-loggregator-ingress-mtls.yml | 2 +- manifest/addon-base-otelcollector-binary.yml | 49 +++++++++++++++++++ packages/otelcollector-linux-amd64/packaging | 21 ++++++-- packages/otelcollector-linux-amd64/spec | 3 +- 5 files changed, 70 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index e978df2..093cd92 100644 --- a/README.md +++ b/README.md @@ -117,7 +117,7 @@ Parameters (see `jobs/otelcollector-bin/spec`): To update the collector deployed by this release: -1. In `packages/otelcollector-linux-amd64/spec` file, update the version of the tar file under `files` section and also the commented URL. +1. In `packages/otelcollector-linux-amd64/spec` file, update the version of the tar file under `files` section and also the commented URL. You can use files with 2 extensions: `.bin` and `.tgz`. 2. Run `./update-blobs.sh`. This will read the commented URL from the previous file, and create the file specified in `files` section. This file will become a *blob* which will be uploaded/synced to the `blobstore`. 3. Upload the release to a Bosh director and test it (see below). 4. Push all blob and package resources to the repository. Check if the pipeline works and check if the generated package (bosh release) works. diff --git a/manifest/addon-add-loggregator-ingress-mtls.yml b/manifest/addon-add-loggregator-ingress-mtls.yml index 788b826..4d62134 100644 --- a/manifest/addon-add-loggregator-ingress-mtls.yml +++ b/manifest/addon-add-loggregator-ingress-mtls.yml @@ -1,5 +1,5 @@ - type: replace - path: /addons?/name=otelcollector-binary/jobs/name=otelcollector-bin/properties/ingress/grpc/tls? + path: /addons?/name=otel-collector-agent/jobs/name=otelcollector-bin/properties/ingress/grpc/tls? value: ca_cert: ((otel_collector_tls.ca)) cert: ((otel_collector_tls.certificate)) diff --git a/manifest/addon-base-otelcollector-binary.yml b/manifest/addon-base-otelcollector-binary.yml index e69de29..ea684d2 100644 --- a/manifest/addon-base-otelcollector-binary.yml +++ b/manifest/addon-base-otelcollector-binary.yml @@ -0,0 +1,49 @@ +releases: +- name: otelcollector-binary + version: latest + +addons: +- name: otel-collector-agent + jobs: + - name: otelcollector-bin + release: otelcollector-binary + properties: + otelcollector-bin: + config: | + extensions: + health_check: + + receivers: + otlp: + protocols: + grpc: + endpoint: ${env:OTELCOL_GRPC_ADDR}:${env:OTELCOL_GRPC_PORT} + + # Collect own metrics + prometheus: + config: + scrape_configs: + - job_name: 'otel-collector' + scrape_interval: 30s + static_configs: + - targets: ['127.0.0.1:8881'] + + processors: + batch: + + exporters: + debug: + verbosity: basic + + service: + logs: + level: INFO + metrics: + level: basic + address: 127.0.0.1:8881 + extensions: [health_check, pprof] + pipelines: + metrics: + receivers: [otlp, prometheus] + processors: [batch] + exporters: [debug] diff --git a/packages/otelcollector-linux-amd64/packaging b/packages/otelcollector-linux-amd64/packaging index 4d24f74..458ca61 100644 --- a/packages/otelcollector-linux-amd64/packaging +++ b/packages/otelcollector-linux-amd64/packaging @@ -2,12 +2,25 @@ set -e -x BOSH_PACKAGES_DIR=${BOSH_PACKAGES_DIR:-/var/vcap/packages} -OTELCOL_VERSION=$(ls -vr otelcollector-linux-amd64/otelcol-contrib_*_linux_amd64.tar.gz | sed 's/.*\/otelcol-contrib_\(.*\)_linux_amd64.tar.gz$/\1/' | head -1) +OTELCOL_VERSION=$(ls -vr otelcollector-linux-amd64/otelcol-contrib_*_linux_amd64* | sed 's/.*\/otelcol-contrib_\(.*\)_linux_amd64.*$/\1/' | head -1) +FILE=$(ls -vr "otelcollector-linux-amd64/otelcol-contrib_${OTELCOL_VERSION}_linux_amd64"* | head -1) -echo "Extracting otel collector version ${OTELCOL_VERSION} ... " mkdir -p ${BOSH_INSTALL_TARGET}/bin -tar xzf "otelcollector-linux-amd64/otelcol-contrib_${OTELCOL_VERSION}_linux_amd64.tar.gz" -C ${BOSH_INSTALL_TARGET} -mv ${BOSH_INSTALL_TARGET}/otelcol-contrib ${BOSH_INSTALL_TARGET}/bin/otelcollector +case "${FILE##*.}" in + bin) + echo "Copying otel collector binary version ${OTELCOL_VERSION} ... " + cp ${FILE} ${BOSH_INSTALL_TARGET}/bin/otelcollector + ;; + tgz) + echo "Extracting otel collector version ${OTELCOL_VERSION} ... " + tar xzf ${FILE} -C ${BOSH_INSTALL_TARGET} + mv ${BOSH_INSTALL_TARGET}/otelcol-contrib ${BOSH_INSTALL_TARGET}/bin/otelcollector + ;; + *) + echo "Unknown file extension, valid types are bin and tgz" + exit 1 + ;; +esac chmod a+x ${BOSH_INSTALL_TARGET}/bin/* # Install shell helpers diff --git a/packages/otelcollector-linux-amd64/spec b/packages/otelcollector-linux-amd64/spec index 352c65f..0b6dff1 100644 --- a/packages/otelcollector-linux-amd64/spec +++ b/packages/otelcollector-linux-amd64/spec @@ -4,5 +4,6 @@ name: otelcollector-linux-amd64 dependencies: [] files: -- otelcollector-linux-amd64/otelcol-contrib_0.100.0_linux_amd64.tar.gz # https://github.com/open-telemetry/opentelemetry-collector-releases/releases/download/v0.100.0/otelcol-contrib_0.100.0_linux_amd64.tar.gz +- otelcollector-linux-amd64/otelcol-contrib_0.107.0_linux_amd64.bin # https://github.com/springernature/o11y-otel-contextprocessor/releases/download/v0.107.0-cfgardenobserver0/otelcol-dev.bin +# - otelcollector-linux-amd64/otelcol-contrib_0.100.0_linux_amd64.tgz # https://github.com/open-telemetry/opentelemetry-collector-releases/releases/download/v0.100.0/otelcol-contrib_0.100.0_linux_amd64.tar.gz - bosh-helpers/**/*