[metrics][docs] Support Basic Auth for Prometheus PushGateway reporter#3552
Open
Guosmilesmile wants to merge 3 commits into
Open
[metrics][docs] Support Basic Auth for Prometheus PushGateway reporter#3552Guosmilesmile wants to merge 3 commits into
Guosmilesmile wants to merge 3 commits into
Conversation
Guosmilesmile
commented
Jul 1, 2026
| this.pushInterval = pushInterval; | ||
| if (username != null && !username.isEmpty()) { | ||
| this.pushGateway.setConnectionFactory( | ||
| basicAuthConnectionFactory(username, password == null ? "" : password)); |
Contributor
Author
There was a problem hiding this comment.
We do not reuse Prometheus' built-in BasicAuthHttpConnectionFactory because it relies on javax.xml.bind.DatatypeConverter for Base64 encoding, which has been removed from the JDK since Java 9 (JEP 320). Using java.util.Base64 keeps this reporter compatible with JDK 8+.
This issue has been resolved at the underlying level in higher versions of the Prometheus dependency, but the current 0.8 version does not include the fix. Upgrading the version rashly may cause problems, so we resolve it here with our own implementation.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Purpose
Linked issue: close #xxx
Currently
PrometheusPushGatewayReportersends metrics to the Prometheus PushGateway anonymously. In production, PushGateway is often placed behind has its own basic auth enabled, which makes the reporter unusable in secured deployments.This PR adds first-class support for Basic Auth on the
prometheus-pushreporter.Brief change log
metrics.reporter.prometheus-push.usernamemetrics.reporter.prometheus-push.passwordPrometheusPushGatewayReporternow injectsio.prometheus.client.exporter.BasicAuthHttpConnectionFactoryinto the underlyingPushGatewaywhen a username is configured; otherwise the behavior is unchanged (noAuthorizationheader is sent).PrometheusPushGatewayReporterPluginreads the two new options and passes them to the reporter. AbasicAuthEnabledflag is logged instead of the raw credentials, so passwords are never printed.Tests
API and Format
Documentation
Add the config to the doc