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

[exporter/prometheusremotewrite] Duplicate attributes when using resource_to_telemetry_conversion #34909

Closed
robertcoltheart opened this issue Aug 28, 2024 · 5 comments

Comments

@robertcoltheart
Copy link

robertcoltheart commented Aug 28, 2024

Component(s)

exporter/prometheusremotewrite

What happened?

Description

When scraping metrics target with a target_info and enabling resource_to_telemetry_conversion on the Prom remote write exporter, some attributes are duplicated and concatenated with ;.

Steps to Reproduce

Scrape target producing the following:

# TYPE target info
# HELP target Target metadata
target_info{telemetry_sdk_name="opentelemetry",telemetry_sdk_language="dotnet",telemetry_sdk_version="1.9.0",deployment_environment="qa",host_name="my-service-7586fcbf74-stwjn",service_name="my-service",service_namespace="my-namespace",service_version="1.10.0",service_instance_id="b61916c5-f387-4f82-a963-9a2220b7121c"} 1

Expected Result

No duplicate values in the final output in Grafana / Loki.

Actual Result

Getting duplicate values in metric attributes concatenated with ';' in deployment_environment, service_instance_id and service_name when this appears in Loki/Grafana. For example deployment_environment="qa;qa".

myservice_load_info {
  container="my-service",
  deployment_environment="qa;qa",
  endpoint="default",
  host_name="my-service-7586fcbf74-stwjn",
  http_scheme="http",
  instance="100.110.191.137:8080",
  job="my-service",
  namespace="ns",
  net_host_name="100.110.191.137",
  net_host_port="8080",
  pod="my-service-569c75b9c4-98gbq",
  server_address="100.110.191.137",
  server_port="8080",
  service="my-service",
  service_instance_id="100.110.191.137:8080;b61916c5-f387-4f82-a963-9a2220b7121c",
  service_name="my-service;my-service",
  service_namespace="my-namespace",
  service_version="1.10.0",
  status="Current",
  telemetry_sdk_language="dotnet",
  telemetry_sdk_name="opentelemetry",
  telemetry_sdk_version="1.9.0",
  url_scheme="http"
}

Collector version

0.104.0

Environment information

Environment

OS: Linux / Kubernetes

OpenTelemetry Collector configuration

targetAllocator:
  enabled: true
  serviceAccount: opentelemetry-collector
  prometheusCR:
    enabled: true
    serviceMonitorSelector: {}
    podMonitorSelector: {}
config:
  receivers:
    prometheus:
      config:
        scrape_configs:
          - job_name: 'opentelemetry-collector'
            scrape_interval: 5s
            static_configs:
              - targets: [ 'localhost:8888' ]
  processors:
    batch: {}
    resource/metrics:
      attributes:
        - action: insert
          key: deployment.environment
          value: qa
  exporters:
    prometheusremotewrite:
      endpoint: https://our-prometheus
      resource_to_telemetry_conversion:
        enabled: true
  service:
    pipelines:
      metrics:
        receivers:
          - prometheus
        processors:
          - batch
          - resource/metrics
        exporters:
          - prometheusremotewrite

Log output

No response

Additional context

No response

@robertcoltheart robertcoltheart added bug Something isn't working needs triage New item requiring triage labels Aug 28, 2024
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

Notes from triage:

  • This happens when two names collide after sanitization. E.g. service.name and service_name both become service_name when translating to PRW.
  • This will be somewhat mitigated with UTF-8 support in prometheus exporters, since service.name will stay service.name.
  • You can fix this by removing (with the resource processor) either the name with dots, or the name with underscores. E.g. removing service.name will keep only the service_name from your target_info metric, and removing service_name will keep only the job from the prometheus receiver (which becomes the service.name).

What behavior did you expect? Did you expect the values from target_info to remain unchanged? Or did you expect the names from your prometheus job/instance to be kept?

@dashpole dashpole removed the needs triage New item requiring triage label Aug 28, 2024
@dashpole dashpole self-assigned this Aug 28, 2024
@robertcoltheart
Copy link
Author

Ok, you're right, dropping the duplicate attributes cleans it up and removes the duplicates. I guess the expectation when using this feature is that the metric names are all sanitized the same way which would eliminate these duplicates. Especially since it seems that Prometheus always outputs '_' regardless of the internal metric name, and Grafana always displays underscores too.

Copy link
Contributor

This issue has been inactive for 60 days. It will be closed in 60 days if there is no activity. To ping code owners by adding a component label, see Adding Labels via Comments, or if you are unsure of which component this issue relates to, please ping @open-telemetry/collector-contrib-triagers. If this issue is still relevant, please ping the code owners or leave a comment explaining why it is still relevant. Otherwise, please close it.

Pinging code owners:

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

@github-actions github-actions bot added the Stale label Oct 28, 2024
Copy link
Contributor

This issue has been closed as inactive because it has been stale for 120 days with no activity.

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Dec 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants