Description
Component(s)
receiver/simpleprometheus
What happened?
Description
From investigation, I believe the simpleprometheus receiver has a bug with how it's passing the label
to the Prometheus receiver's configuration. This issue was introduced in v0.127.0
. This functionality has been working, but was technically wrong before this release. Change in behavior of the Prometheus receiver has simply exposed this issue, and it's now a bug.
Source of issue:
This was exposed by a Prometheus upgrade PR, specifically the PromConfig.Reload
functionality. Inside the PromConfig.Reload
there's a call to yaml.Unmarshal
, which doesn't unmarshal the values in the form they're being passed.
Prometheus has its own MarshalYaml function that is only taking the model.Address
label value for the targets YAML entry. This marshalling functionality hasn't been changed in a long time, it looks like it just wasn't being exercised by this code path until now.
This was working before the upgrade PR because labels are being added to the target in the TargetsFromGroup method which has no filtering based on label name (so any label found will be added to the target's list of labels) The target's labels are then used in mutateReportSampleLabels to add to the current metric's labels.
Proposed Solution:
Original two lines
Proposed new lines:
Targets: []model.LabelSet{{model.AddressLabel: model.LabelValue(cfg.Endpoint)}},
Labels: labels,
This would align the purpose and functionality of the static_config.
Steps to Reproduce
Run the collector with the provided configuration
Expected Result
Contents from v0.126.0
:
Metric #2
Descriptor:
-> Name: scrape_duration_seconds
-> Description: Duration of the scrape
-> Unit: s
-> DataType: Gauge
NumberDataPoints #0
Data point attributes:
-> example_label: Str(example_value)
StartTimestamp: 1970-01-01 00:00:00 +0000 UTC
Timestamp: 2025-06-13 22:27:53.531 +0000 UTC
Value: 0.001685
Actual Result
Results from v0.127.0
:
Metric #1
Descriptor:
-> Name: scrape_duration_seconds
-> Description: Duration of the scrape
-> Unit: s
-> DataType: Gauge
NumberDataPoints #0
StartTimestamp: 1970-01-01 00:00:00 +0000 UTC
Timestamp: 2025-06-13 22:31:02.968 +0000 UTC
Value: 0.003895
Collector version
v0.127.0
Environment information
Environment
OS: (e.g., "Ubuntu 20.04")
Compiler(if manually compiled): (e.g., "go 14.2")
OpenTelemetry Collector configuration
receivers:
prometheus_simple:
collection_interval: 1s
labels:
example_label: example_value
exporters:
debug:
verbosity: detailed
service:
pipelines:
metrics:
receivers: [prometheus_simple]
exporters: [debug]
Log output
Additional context
No response