Skip to content

[receiver/statsdreceiver] Add ability to customize permissions of socket when using UDS server #37807

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

Closed
thomas-gouveia opened this issue Feb 10, 2025 · 3 comments · Fixed by #38420
Labels
enhancement New feature or request needs triage New item requiring triage receiver/statsd statsd related issues

Comments

@thomas-gouveia
Copy link
Contributor

Component(s)

receiver/statsd

Is your feature request related to a problem? Please describe.

We have some apps deployed in Kubernetes configured to send metrics to Datadog through the unix datagram socket managed by the Datadog agent in /var/run/datadog/dsd.socket. We're currently exploring a solution to deploy a drop-in replacement of the Datadog agent using a combination of statsdreceiver and datadogreceiver in the collector.

We have a PoC deployed and that works properly, but we have a little issue with the permissions of the socket bind by the statsdreceiver. If the application doesn't run with the same user than the collector, it won't be able to write to the socket because of the following permissions on the socket (default one I assume):

ls -l /var/run/

total 0
srwx-w--w- 1 root root 0 Feb  10 13:53 statsd-receiver.sock

So only owner of the socket is able to write (in that case, root). In comparison the Datadog agent socket has the following permissions:

ls -l /var/run/datadog 

total 0
srwx-w--w- 1 root root 0 Jan  3 15:53 dsd.socket

Describe the solution you'd like

To solve the issue, I propose to call a chmod with 0622 right after the bind call to ensure permissions of the socket are managed by the receiver itself.

If needed, we can also introduce in the configuration a new attribute to allow customization of permissions, and make 0622 as default :

config:
  receivers:
    statsd:
      transport: unixgram
      endpoint: /path/to/statsd.socket
      perms: 0622

Describe alternatives you've considered

  • Usage of initContainers running as root to run chmod/chown: it works but if the collector restarts, permissions are reset when it binds again.
  • Usage of fsGroup, not working

Additional context

I can propose a fix for this issue 👍

@thomas-gouveia thomas-gouveia added enhancement New feature or request needs triage New item requiring triage labels Feb 10, 2025
Copy link
Contributor

Pinging code owners:

See Adding Labels via Comments if you do not have permissions to add labels yourself.

@jmacd
Copy link
Contributor

jmacd commented Feb 21, 2025

Looks good to me, please go ahead!

@thomas-gouveia
Copy link
Contributor Author

Sorry for my late response @jmacd, missed the notification! Will open the PR 👍

thomas-gouveia added a commit to thomas-gouveia/opentelemetry-collector-contrib that referenced this issue Mar 6, 2025
thomas-gouveia added a commit to thomas-gouveia/opentelemetry-collector-contrib that referenced this issue Mar 6, 2025
thomas-gouveia added a commit to thomas-gouveia/opentelemetry-collector-contrib that referenced this issue Mar 7, 2025
thomas-gouveia added a commit to thomas-gouveia/opentelemetry-collector-contrib that referenced this issue Mar 7, 2025
thomas-gouveia added a commit to thomas-gouveia/opentelemetry-collector-contrib that referenced this issue Mar 10, 2025
thomas-gouveia added a commit to thomas-gouveia/opentelemetry-collector-contrib that referenced this issue Mar 10, 2025
thomas-gouveia added a commit to thomas-gouveia/opentelemetry-collector-contrib that referenced this issue Mar 11, 2025
thomas-gouveia added a commit to thomas-gouveia/opentelemetry-collector-contrib that referenced this issue Mar 11, 2025
thomas-gouveia added a commit to thomas-gouveia/opentelemetry-collector-contrib that referenced this issue Mar 21, 2025
thomas-gouveia added a commit to thomas-gouveia/opentelemetry-collector-contrib that referenced this issue Mar 24, 2025
thomas-gouveia added a commit to thomas-gouveia/opentelemetry-collector-contrib that referenced this issue Apr 1, 2025
thomas-gouveia added a commit to thomas-gouveia/opentelemetry-collector-contrib that referenced this issue Apr 7, 2025
akshays-19 pushed a commit to akshays-19/opentelemetry-collector-contrib that referenced this issue Apr 23, 2025
… when transport is unixgram (open-telemetry#37807) (open-telemetry#38420)

#### Description

This PR introduces a new configuration key `socket_permissions` used
when `transport: unixgram` to control permissions of the bind socket.

#### Link to tracking issue

Fixes
open-telemetry#37807

#### Testing

Unit tests

#### Documentation

Readme updated with new configuration

Signed-off-by: thomas-gouveia <[email protected]>
Fiery-Fenix pushed a commit to Fiery-Fenix/opentelemetry-collector-contrib that referenced this issue Apr 24, 2025
… when transport is unixgram (open-telemetry#37807) (open-telemetry#38420)

#### Description

This PR introduces a new configuration key `socket_permissions` used
when `transport: unixgram` to control permissions of the bind socket.

#### Link to tracking issue

Fixes
open-telemetry#37807

#### Testing

Unit tests

#### Documentation

Readme updated with new configuration

Signed-off-by: thomas-gouveia <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request needs triage New item requiring triage receiver/statsd statsd related issues
Projects
None yet
2 participants