open-telemetry / opentelemetry-collector-contrib

Contrib repository for the OpenTelemetry Collector
https://opentelemetry.io
Apache License 2.0
2.75k stars 2.18k forks source link

Access to journal files running in container on k8s #33104

Open omri-cavnue opened 2 months ago

omri-cavnue commented 2 months ago

Component(s)

receiver/journald

What happened?

Description

I was able to set up my own custom docker image that has the journalctl binary for arm64. However, I now get the following error:

journalctl command failed (exit status 1): No journal files were opened due to insufficient permissions.

I tried running the container as privileged, but the error is still there. What permission is required to read it from a container? I am mounting /run/log/journal.

On host I can run journalctl as user without any root auth needed

Steps to Reproduce

Expected Result

Actual Result

Collector version

arm64:latest

Environment information

Environment

Jetson Jetpack 35.4.1 Compiler(if manually compiled): (e.g., "go 14.2")

OpenTelemetry Collector configuration

journald:
    directory: /run/log/journal
    units:
      - ssh
    priority: info

Log output

No response

Additional context

No response

github-actions[bot] commented 2 months ago

Pinging code owners:

sumo-drosiek commented 2 months ago

Could you run ls -al /run/log/journal inside the container?

omri-cavnue commented 2 months ago

Running ps faux | grep otel shows that the container is running with user 1001 (likely random user). However, when I try to build with USER root or create a user and add it to systemctl group, the container goes into crashloop. This is definitely the problem though as likely 1001 doesn't have permission

Not really sure why setting user as root causes it to fallover

omri-cavnue commented 2 months ago

Looks like it's from the base otel image . Otel base image has no shell since it's from scratch, so having trouble getting around this

omri-cavnue commented 2 months ago

I was finally able to figure out by building a custom image. This doesn't seem very scalable IMO

sumo-drosiek commented 1 month ago

@omri-cavnue Did you try to run container with the root user (using --user argument)?