Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Running Custom Otel Collector causing Exec format error #790

Open
FoxeyesJK opened this issue Dec 26, 2024 · 1 comment
Open

Running Custom Otel Collector causing Exec format error #790

FoxeyesJK opened this issue Dec 26, 2024 · 1 comment
Labels
artifact:docker bug Something isn't working

Comments

@FoxeyesJK
Copy link

FoxeyesJK commented Dec 26, 2024

Hi, I'm new to otel and trying to build a custom collector running our own docker image.

I've been reading the official documentation, and achieved following so far

  1. using ocb compiler to generate go components with a custom manifest.yaml
  2. built a docker image custom-collector:0.1.8 using Dockerfile
  3. ran docker run, but faced a syntax error as below.

I'm stuck here running the docker container with what I have below. Any suggestion I can try?

  • I am using M2 Chip MAC(ARM)
  • I tried with the v0.116.0 and had a same problem. Seems like OCB doesn't have v0.116.1(latest) yet
  • From scratch in Dockerfile LN4 was causing an error and switched to using alpine to at least running it

docker run -it --entrypoint sh custom-collector:0.1.8

/otelcol-contrib: line 1: ����

                              : not found

/otelcol-contrib: line 2: syntax error: unexpected "(" 

Dockerfile

FROM alpine:latest AS prep
RUN sed -i "s@http://dl-cdn.alpinelinux.org/alpine/@https://artifactory.aexp.com/alpine-raw/@g" /etc/apk/repositories
RUN sed -i "s@https://dl-cdn.alpinelinux.org/alpine/@https://artifactory.aexp.com/alpine-raw/@g" /etc/apk/repositories
RUN apk --update add ca-certificates

FROM alpine:latest

ARG USER_UID=10001
ARG USER_GID=10001
USER ${USER_UID}:${USER_GID}

COPY --from=prep /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt
COPY --chmod=755 otelcol-custom/otelcol-custom /otelcol-contrib
COPY config.yaml /etc/otelcol-contrib/config.yaml
ENTRYPOINT ["/otelcol-contrib"]
CMD ["--config", "/etc/otelcol-contrib/config.yaml"]
EXPOSE 4317 4318 55678 55679

config.yaml

receivers:
  otlp:
    protocols:
      grpc:
        endpoint: [0.0.0.0:4317](http://0.0.0.0:4317/)
      http:
        endpoint: [0.0.0.0:4318](http://0.0.0.0:4318/)

processors:
  batch:

exporters:
  debug:
    verbosity: detailed
  otlp/jaeger:
    endpoint: jaeger-all-in-one:4317
    tls:
      insecure: true

extensions:
  health_check:
  zpages:
    endpoint: :55679

service:
  extensions: [zpages, health_check]
  pipelines:
    traces:
      receivers: [otlp]
      processors: [batch]
      exporters: [otlp/jaeger]
    metrics:
      receivers: [otlp]
      processors: [batch]
      exporters: [debug]
    logs:
      receivers: [otlp]
      processors: [batch]
      exporters: [debug]

manifest.yaml

dist:
  module: [github.com/betterstack-community/otelcol-custom](http://github.com/betterstack-community/otelcol-custom)
  name: otelcol-custom
  description: Custom OTel Collector distribution
  output_path: ./otelcol-custom
  version: 0.110.0

receivers:
  - gomod: [go.opentelemetry.io/collector/receiver/otlpreceiver](http://go.opentelemetry.io/collector/receiver/otlpreceiver) v0.110.0
  - gomod: [github.com/open-telemetry/opentelemetry-collector-contrib/receiver/jaegerreceiver](http://github.com/open-telemetry/opentelemetry-collector-contrib/receiver/jaegerreceiver) v0.110.0

processors:
  - gomod: [go.opentelemetry.io/collector/processor/batchprocessor](http://go.opentelemetry.io/collector/processor/batchprocessor) v0.110.0
  - gomod: [go.opentelemetry.io/collector/processor/memorylimiterprocessor](http://go.opentelemetry.io/collector/processor/memorylimiterprocessor) v0.110.0
  - gomod: [github.com/open-telemetry/opentelemetry-collector-contrib/processor/attributesprocessor](http://github.com/open-telemetry/opentelemetry-collector-contrib/processor/attributesprocessor) v0.110.0
  - gomod: [github.com/open-telemetry/opentelemetry-collector-contrib/processor/filterprocessor](http://github.com/open-telemetry/opentelemetry-collector-contrib/processor/filterprocessor) v0.110.0
  - gomod: [github.com/open-telemetry/opentelemetry-collector-contrib/processor/redactionprocessor](http://github.com/open-telemetry/opentelemetry-collector-contrib/processor/redactionprocessor) v0.110.0
  - gomod: [github.com/open-telemetry/opentelemetry-collector-contrib/processor/transformprocessor](http://github.com/open-telemetry/opentelemetry-collector-contrib/processor/transformprocessor) v0.110.0

exporters:
  - gomod: [go.opentelemetry.io/collector/exporter/debugexporter](http://go.opentelemetry.io/collector/exporter/debugexporter) v0.110.0
  - gomod: [go.opentelemetry.io/collector/exporter/otlpexporter](http://go.opentelemetry.io/collector/exporter/otlpexporter) v0.110.0

extensions:
  - gomod: [go.opentelemetry.io/collector/extension/zpagesextension](http://go.opentelemetry.io/collector/extension/zpagesextension) v0.110.0
  - gomod: [github.com/open-telemetry/opentelemetry-collector-contrib/extension/healthcheckextension](http://github.com/open-telemetry/opentelemetry-collector-contrib/extension/healthcheckextension) v0.110.0
  - gomod: [github.com/open-telemetry/opentelemetry-collector-contrib/extension/encoding/jaegerencodingextension](http://github.com/open-telemetry/opentelemetry-collector-contrib/extension/encoding/jaegerencodingextension) v0.110.0
  - gomod: [github.com/open-telemetry/opentelemetry-collector-contrib/extension/jaegerremotesampling](http://github.com/open-telemetry/opentelemetry-collector-contrib/extension/jaegerremotesampling) v0.110.0

providers:
  - gomod: [go.opentelemetry.io/collector/confmap/provider/envprovider](http://go.opentelemetry.io/collector/confmap/provider/envprovider) v1.16.0
  - gomod: [go.opentelemetry.io/collector/confmap/provider/fileprovider](http://go.opentelemetry.io/collector/confmap/provider/fileprovider) v1.16.0
  - gomod: [go.opentelemetry.io/collector/confmap/provider/httpprovider](http://go.opentelemetry.io/collector/confmap/provider/httpprovider) v0.110.0
  - gomod: [go.opentelemetry.io/collector/confmap/provider/httpsprovider](http://go.opentelemetry.io/collector/confmap/provider/httpsprovider) v0.110.0
  - gomod: [go.opentelemetry.io/collector/confmap/provider/yamlprovider](http://go.opentelemetry.io/collector/confmap/provider/yamlprovider) v0.110.0
Copy link

dosubot bot commented Dec 26, 2024

Hey there, @FoxeyesJK! 👋 I'm here to help you out with your otel custom collector issue. I'm a bot that can help you solve bugs, answer questions, and become a contributor. Let's figure this out together!

The "Exec format error" you're encountering is likely due to the binary being built for a different architecture than the one your Docker image is running on. This can happen if the binary is not statically linked or if it requires libraries that are not present in the Alpine Linux base image.

Here are a few steps you can take to resolve this issue:

  1. Ensure Correct Architecture: Make sure that the binary you are copying into the Docker image is built for the correct architecture. If you are building on a different architecture than the one you are targeting (e.g., building on an x86_64 machine for an ARM target), you need to cross-compile the binary.

  2. Static Linking: Ensure that the binary is statically linked. This can be done by setting the CGO_ENABLED=0 environment variable when building the Go binary. This will ensure that the binary does not depend on any shared libraries that might not be present in the Alpine image.

    CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o otelcol-custom
  3. Use a Compatible Base Image: If the binary is dynamically linked, consider using a base image that includes the necessary libraries. For example, using a debian or ubuntu base image might include the required libraries.

  4. Check Binary Compatibility: Verify that the binary is not corrupted and is executable. You can do this by running the binary on a similar environment outside of Docker to ensure it works as expected.

  5. Use a Known Working Version: If the issue persists, consider using a known working version of the OpenTelemetry Collector that includes statically linked binaries, such as version 0.115.1, which does not have issues with dynamically linked binaries requiring external libraries [1].

By following these steps, you should be able to resolve the "Exec format error" and successfully run your custom OpenTelemetry Collector Docker image.

To continue talking to Dosu, mention @dosu.


Help Dosu learn! Give it feedback: Great Response | Irrelevant Answer | Incorrect Sources | Too Verbose | Hallucination | Other

@dosubot dosubot bot added artifact:docker bug Something isn't working labels Dec 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
artifact:docker bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant