Skip to content

[receiver/hostmetrics] Emit unique service.instance.id attribute per resource for interoperability with Prometheus as OTel backend #46207

@aknuds1

Description

@aknuds1

Component(s)

receiver/hostmetrics

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

The hostmetrics receiver emits resource attributes without service.instance.id or service.name. This prevents interoperability with Prometheus as OTel backend. For reference, per the Prometheus OpenTelemetry guide Prometheus treats service.instance.id and service.name as identifying resource attributes. The documentation states:

If a resource lacks both service.instance.id and service.name attributes, no corresponding target_info series is generated.

This means that when hostmetrics receiver metrics are sent to Prometheus via OTLP, all resource attributes are silently dropped — no target_info metric for encoding resource attributes is generated at all. The effect is that all resource context (hostname, OS info, etc.) is lost without warning.

The OTLP to Prometheus compatibility spec further mandates that service.instance.id MUST map to the Prometheus instance label and service.name to job. Without these, metrics from different hosts are indistinguishable — the instance label gets an empty value, collapsing all hosts into a single target.

The combined effect is:

  1. No target_info metric generated: All resource attributes are lost
  2. No instance label: Host metrics from different machines cannot be distinguished
  3. No host-to-process correlation: Cannot correlate host-level metrics with process-level metrics from the same machine

To work around the receiver not sending identifying resource attributes recognized by Prometheus, users currently have to add a resourcedetectionprocessor to the OTel Collector pipeline to emit these attributes.

Describe the solution you'd like

I propose adding a deterministic service.instance.id resource attribute to all scrapers in the hostmetrics receiver:

  • For host-level scrapers (cpu, disk, filesystem, load, memory, network, nfs, paging, processes, system): a UUID v5 derived from the hostname using the OTel namespace UUID (4d63009a-8d0f-11ee-aad7-4c796ed8e320), following the semantic conventions recommendation for deterministic ID generation
  • For the process scraper: a unique UUID v5 per process, derived from the base hostname UUID combined with the process PID — ensuring each monitored process is a distinct Prometheus target

Describe alternatives you've considered

  • resourcedetectionprocessor — works but requires extra pipeline config, doesn't provide per-process uniqueness
  • Random UUIDs — not deterministic, change on collector restart, would create new Prometheus time series on every restart
  • Collector-level service config — no per-process support for the process scraper

Additional context

Additional context

Tip

React with 👍 to help prioritize this issue. Please use comments to provide useful context, avoiding +1 or me too, to help us triage it. Learn more here.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions