-
Notifications
You must be signed in to change notification settings - Fork 41.2k
Add basic auth support for Prometheus pushgateway #22548
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
Add basic auth support for Prometheus pushgateway #22548
Conversation
@AndrewDi Please sign the Contributor License Agreement! Click here to manually synchronize the status of this Pull Request. See the FAQ for frequently asked questions. |
@AndrewDi Thank you for signing the Contributor License Agreement! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for submitting your first PR. I've added a few comments. Can you please also update PrometheusMetricsExportAutoConfigurationTests
to add the necessary tests that exercise this change?
/** | ||
* Enable publishing via a Prometheus Pushgateway with Basic Auth. | ||
*/ | ||
private Boolean authEnabled = false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't have such enabled
flag. What we usually do is to check that the username is set, something like StringUtils.hasText
can help you with that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you mean check this value in PrometheusMetricsExportAutoConfigurationTests
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No. I mean that we don't enable authentication based on a flag but based on the fact that the username
property is set.
...ringframework/boot/actuate/autoconfigure/metrics/export/prometheus/PrometheusProperties.java
Outdated
Show resolved
Hide resolved
private Boolean authEnabled = false; | ||
|
||
/** | ||
* Basic Auth Username. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure if "basic auth" is really important here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pushgateway already support basic auth, we just need to pass auth parameters to setConnectionFactory
function.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am aware of that. The comment is on the key description.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok
...ringframework/boot/actuate/autoconfigure/metrics/export/prometheus/PrometheusProperties.java
Outdated
Show resolved
Hide resolved
@AndrewDi how is it going? Did you get a chance to look at the review? |
I've decided to give this one anyway, see this polish commit. |
We hide pushgateway behind nginx, and use HTTP basic auth, so need pushgateway to implement it.