open-telemetry / opentelemetry-collector-contrib

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

postgresql receiver should output hostname with metrics #33709

Closed nsteinmetz closed 1 week ago

nsteinmetz commented 1 week ago

Component(s)

receiver/postgresql

What happened?

Description

I setup otelcol-contrib on two servers - I can't filter metrics per hostname. So I have only an aggregated view of metrics.

Steps to Reproduce

Launch 2 instances of postgres, one is primary, one is replica Launch otelcol-contrib on both instances

Expected Result

being able to filter metrics per hostname

Actual Result

No filtering per hostname

Collector version

0.103.0

Environment information

Environment

OS: (e.g., "Ubuntu 20.04") Compiler(if manually compiled): (e.g., "go 14.2")

OpenTelemetry Collector configuration

No response

Log output

No response

Additional context

No response

github-actions[bot] commented 1 week ago

Pinging code owners:

nsteinmetz commented 1 week ago

Ok found how to do it, just add the resourcedetection processor and add it in the pipeline configuration

  processors:
    resourcedetection:
      detectors: [env, system]
[...]
  service:
    pipelines:
      traces:
        receivers: [otlp]
        processors: [batch]
        exporters: [otlp/uptrace, debug]
      metrics:
        receivers: [otlp, postgresql]
        processors: [cumulativetodelta, batch, resourcedetection]
        exporters: [otlp/uptrace, debug]