Open
Description
Component(s)
No response
What happened?
Description
The Prometheus receiver fails to scrape and endpoint with basic authentication enabled.
Steps to Reproduce
- Set up basic authentication for a Prometheus endpoint, in this case 192.168.0.8:5572/metrics
- Configure basic_auth in the scrape config
- Start collector
Expected Result
Prometheus receiver is able to scrape the endpoint.
Actual Result
Scrape fails with 401 Unauthorized
Collector version
v0.127.0
Environment information
Environment
OS: Ubuntu 24.04.2 LTS
OpenTelemetry Collector configuration
receivers:
prometheus:
config:
scrape_configs:
- job_name: integrations/rclone
metrics_path: /metrics
scrape_interval: 30s
static_configs:
- targets: ['192.168.0.8:5572']
basic_auth:
username: "USR"
password: "PWD"
relabel_configs:
- source_labels: [__address__]
action: replace
target_label: instance
metric_relabel_configs:
- source_labels: [__name__]
action: keep
regex: "up|rclone_.*"
processors:
cumulativetodelta:
resourcedetection/dynatrace:
override: false
detectors: [dynatrace]
Log output
2025-06-06T09:48:43.196Z debug Scrape failed {"resource": {}, "otelcol.component.id": "prometheus", "otelcol.component.kind": "receiver", "otelcol.signal": "metrics", "scrape_pool": "integrations/rclone", "target": "http://192.168.0.8:5572/metrics", "err": "server returned HTTP status 401 Unauthorized"}
2025-06-06T09:48:43.196Z warn internal/transaction.go:150 Failed to scrape Prometheus endpoint {"resource": {}, "otelcol.component.id": "prometheus", "otelcol.component.kind": "receiver", "otelcol.signal": "metrics", "scrape_timestamp": 1749203323194, "target_labels": "{__name__=\"up\", instance=\"192.168.0.8:5572\", job=\"integrations/rclone\"}"}
Additional context
- Verified that the enpoint is reachable
- Verified that enpont returns 401 Unauthorized without providing basic authentication using curl 192.168.0.8:5572/metrics
- Verified that the endpoint returns the Prometheus metrics using curl -u USER:PWD 192.168.0.8:5572/metrics