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

[processor/resourcedetection] Container env OTEL_RESOURCE_ATTRIBUTES not extracted when using pull receiver like prometheus, redis... #37473

Open
sswieton opened this issue Jan 24, 2025 · 4 comments
Labels
processor/resourcedetection Resource detection processor question Further information is requested receiver/redis Redis related issues

Comments

@sswieton
Copy link

Component(s)

processor/resourcedetection

What happened?

Description

I would like to enrich resource attributes with environment variables defined in the containers using OTEL_RESOURCE_ATTRIBUTES variable
To achieve this, I used the resourcedetection processor.

The problem occurs only for pods detected by pull receivers. I have reproduced it with the Prometheus and Redis receivers.
The resource detection processor enriches Resource attributes with only system metadata and not env variables.**

Steps to Reproduce

I used a Pull receiver like redisreceiver or prometheusreceiver

receivers:
    redis:
      endpoint: "redis-otlp-tcp:6379"
      collection_interval: 10s
      password: pwd
      username: user

processor resourcedetection

    resourcedetection:
      detectors: [env,system]
      timeout: 2s
      override: false

Expected Result

The objective is to enrich resource attributes with attributes that allow the execution of k8sattributes ( and the pod_association)

Actual Result

In the Resource Attributes, I can only get information related to the system, not the env

Resource SchemaURL: https://opentelemetry.io/schemas/1.6.1
Resource attributes:
     -> redis.version: Str(7.2.5)
     -> host.name: Str(otel-collector-sandbox-7bb68868c7-6g884)
     -> os.type: Str(linux)
ScopeMetrics #0
ScopeMetrics SchemaURL:
InstrumentationScope github.com/open-telemetry/opentelemetry-collector-contrib/receiver/redisreceiver 0.115.0


Collector version

0.115.1

Environment information

Environment

Kubernetes.
Version : Chart Helm opentelemetry-collector-0.111.1
app Version : 0.115.1

OpenTelemetry Collector configuration

metrics:
        receivers:
          - redis
        processors:
          - resourcedetection
          - batch
        exporters: 
          - debug/verbose

Log output

Additional context

No response

@sswieton sswieton added bug Something isn't working needs triage New item requiring triage labels Jan 24, 2025
@github-actions github-actions bot added the processor/resourcedetection Resource detection processor label Jan 24, 2025
Copy link
Contributor

Pinging code owners:

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

@dashpole
Copy link
Contributor

The resource detection processor's env detector will add resource attributes from the OTEL_RESOURCE_ATTRIBUTES env var set on the collector's container, not set on application containers.

For the prometheus receiver, I would recommend using kubernetes service discovery (kubernetes_sd_config). If you use the pod role, the prometheus receiver will add some k8s.* resource attributes automatically, which you could further enrich with metadata from the k8sattributes processor if you wanted (or it may already have enough).

For redis, the redis receiver would need to support some form of resource attribute for it to work.

@dashpole dashpole added question Further information is requested receiver/redis Redis related issues and removed bug Something isn't working needs triage New item requiring triage labels Jan 24, 2025
Copy link
Contributor

Pinging code owners for receiver/redis: @dmitryax @hughesjj. See Adding Labels via Comments if you do not have permissions to add labels yourself. For example, comment '/label priority:p2 -needs-triaged' to set the priority and remove the needs-triaged label.

@sswieton
Copy link
Author

sswieton commented Jan 24, 2025

Thank you for your quick responses.
Perhaps this information could be specified in the README of the resourceReceiver processor. I was confused.
For the Prometheus receiver, indeed, kubernetes_sd_confi allows retrieving the necessary metadata. that's great.

Regarding Redis, it would indeed be necessary to add additional metadata, as currently, we only retrieve the Redis version, which is not sufficient to enrich the data using k8sattributes processor

Many Thanks for your support

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
processor/resourcedetection Resource detection processor question Further information is requested receiver/redis Redis related issues
Projects
None yet
Development

No branches or pull requests

2 participants