Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[receiver/prometheusreceiver] Fix retrieval of aggregated metrics wit…
…h no job/instance label (open-telemetry#33565) **Description:** This PR fixes the retrieval of metrics where either the `job` or `instance` label is missing, and `honor_labels` is set to `true`. This can be the case for aggregated metrics coming from a federate endpoint. This PR introduces a fallback to using the `job`/`instance` labels from the scrape config for such metrics. **Link to tracking Issue:** Fixes open-telemetry#32555 **Testing:** - Added a Unit test - Verified using the following config: ``` receivers: prometheus: config: scrape_configs: - job_name: 'federate' scrape_interval: 10s honor_labels: true params: 'match[]': - '{__name__="cluster:node_cpu:sum_rate5m"}' metrics_path: '/federate' static_configs: - targets: - "localhost:9090" exporters: debug: verbosity: detailed otlphttp: endpoint: ${env:OTLP_ENDPOINT} pipelines: metrics: receivers: [otlp,prometheus] exporters: [otlphttp, debug] ``` This was tested on a `kind` K8s cluster running the prometheus operator, with a port forward for the `prometheus-k8s` service created by the prometheus operator (therefore the `localhost:9090` address in the target). --------- Signed-off-by: Florian Bacher <[email protected]> Co-authored-by: David Ashpole <[email protected]>
- Loading branch information