Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

serviceMonitor not sending correct password from secret using basicAuth #1018

Open
rjackson-fr opened this issue Nov 28, 2024 · 17 comments
Open

Comments

@rjackson-fr
Copy link

I have defined a serviceMonitor for an application where the scrape endpoint requires basic authentication. It constantly fails with a 401 error. I have confirmed the username and password values in my secret are correct and that the serviceaccount can get the secret. I can shell into the metric pod and use curl curl http://10.244.1.xxx:8080/metrics/prometheus --user prometheus:prometheus and successfully retrieve the metric data

I deployed a similar test deployment/service/serviceMonitor using image mendhak/http-https-echo in order to see the raw value of the authorization header, and it appears that it is sending the text <secret> as the password:

cHJvbWV0aGV1czo8c2VjcmV0Pg== = prometheus:<secret>

{ "path": "/test", "headers": { "host": "10.244.2.xxx:8080", "user-agent": "custom-collector-distro/0.99.0", "accept": "application/openmetrics-text;version=1.0.0;q=0.5,application/openmetrics-text;version=0.0.1;q=0.4,text/plain;version=0.0.4;q=0.3,*/*;q=0.2", "accept-encoding": "gzip", "authorization": "Basic cHJvbWV0aGV1czo8c2VjcmV0Pg==", "x-prometheus-scrape-timeout-seconds": "10" }, "method": "GET", "body": "", "fresh": false, "hostname": "10.244.2.xxx", "ip": "::ffff:10.244.0.xxx", "ips": ], "protocol": "http", "query": {}, "subdomains": ], "xhr": false, "os": { "hostname": "nginx-deployment-xxxxxxxx-xxxx" }, "connection": {} }

Copy link

github-actions bot commented Dec 6, 2024

This issue is stale because it has been open 7 days with no activity. Remove stale label or comment or this will be closed in 5 days.

@rjackson-fr
Copy link
Author

rjackson-fr commented Dec 9, 2024

FYI: I have confirmed this theory by changing the password on the applications to <secret> and the serviceMonitor collector is now working

Copy link

This issue is stale because it has been open 7 days with no activity. Remove stale label or comment or this will be closed in 5 days.

Copy link

This issue was closed because it has been stalled for 12 days with no activity.

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Dec 23, 2024
@rjackson-fr
Copy link
Author

Can this be re-opened? It is not fixed

@vishiy vishiy reopened this Dec 23, 2024
@vishiy
Copy link
Contributor

vishiy commented Dec 23, 2024

hi @rjackson-fr - just reopened it to track and fix this issue .

@rjackson-fr
Copy link
Author

Thank you!

@rjackson-fr
Copy link
Author

I see that this unit test is expecting the static string in a test case, but not sure where the actual config is parsed at runtime.

https://github.com/Azure/prometheus-collector/blob/main/otelcollector/otel-allocator/server/server_test.go#L538

Copy link

github-actions bot commented Jan 1, 2025

This issue is stale because it has been open 7 days with no activity. Remove stale label or comment or this will be closed in 5 days.

Copy link

github-actions bot commented Jan 9, 2025

This issue is stale because it has been open 7 days with no activity. Remove stale label or comment or this will be closed in 5 days.

@rjackson-fr
Copy link
Author

bump

@gracewehner
Copy link
Contributor

Hi @rjackson-fr, thanks for your issue. For the password to be sent from the otel-allocator to the ama-metrics replica pods, it needs to be sent over HTTPS. We have plans to implement this in the future. The workaround is to use the ama-metrics-prometheus-config configmap with a Prometheus scrape config instead of a service monitor for now.

Here's some of the docs to do so:

@rjackson-fr
Copy link
Author

@gracewehner thanks - that is interesting. I already have a workaround mentioned above, so I will stick with the service monitor for now.

Is that a design choice based on sending the password over non-TLS connection between the monitoring components? Ultimately the password will also be sent to the scraping endpoint on the monitored service pod, and these are often non-TLS behind the ingress anyway. Since the ama-metrics pods are also kubernetes, does it make more sense to have them fetch the secret directly rather than have it fetched and passed from the otel-allocator?

-Rob

Copy link

This issue is stale because it has been open 7 days with no activity. Remove stale label or comment or this will be closed in 5 days.

Copy link

This issue is stale because it has been open 7 days with no activity. Remove stale label or comment or this will be closed in 5 days.

Copy link

github-actions bot commented Feb 4, 2025

This issue was closed because it has been stalled for 12 days with no activity.

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Feb 4, 2025
@vishiy vishiy reopened this Feb 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants