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

[receiver/vcenterreceiver] No attributes to define datacenter #32531

Closed StefanKurek closed 2 months ago

StefanKurek commented 3 months ago

Component(s)

receiver/vcenter

What happened?

Description

Currently, when collecting against any environment, none of the existing resources have resource attributes that define which datacenter they belong to. If there were multiple datacenters, this could cause confusion and even allow for the possibility of two resources with the exact same resource attribute key/values.

Steps to Reproduce

Collect against any vCenter environment.

Expected Result

All returned resources have a vcenter.datacenter.name resource attribute

Actual Result

No returned resources have resource attributes related to datacenter

Collector version

v1.5.0/v0.98.0

Environment information

No response

OpenTelemetry Collector configuration

extensions:
  basicauth/prom:
    client_auth:
      username: [PROMUSER]
      password: [PROMPASS]

exporters:
  prometheusremotewrite:
    endpoint: [PROMENDPOINT]
    auth:
      authenticator: basicauth/prom
    resource_to_telemetry_conversion:
      enabled: true # Convert resource attributes to metric labels

processors:
  batch:
    # https://github.com/open-telemetry/opentelemetry-collector/tree/main/processor/batchprocessor

receivers:
  vcenter:
    endpoint: https://[VCENTERHOST]
    username: [VCENTERUSER]
    password: [VCENTERPASS]
    tls:
      insecure: true
    collection_interval: 1m
    initial_delay: 1s

service:
  extensions: [basicauth/prom]
  pipelines:
    metrics:
      receivers: [vcenter]
      processors: [batch]
      exporters: [prometheusremotewrite]

Log output

No response

Additional context

No response

github-actions[bot] commented 3 months ago

Pinging code owners:

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

djaglowski commented 2 months ago

To clarify, this attribute would be applied to all resources emitted by the receiver, because all the components described are always associated with one data center. Is that right?

If so, this makes sense to me. We need to add it first as an optional resource attribute and can enable it by default in a future version. Same mechanism as https://github.com/open-telemetry/opentelemetry-collector-contrib/issues/24071#issuecomment-2066775491 should be used.

StefanKurek commented 2 months ago

@djaglowski yep, right now I think it makes the most sense to put it on every single resource type. I can update the related PR to do as you suggested with the optional resource attribute.

StefanKurek commented 2 months ago

@djaglowski You mention a warning log in the linked issue with a version (when is this log emitted?). Is this relevant to this attribute as well?

djaglowski commented 2 months ago

Yes, we'll have to do it before enabling the attribute by default. Adding it immediately seems fine to me.