You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We're using the client to query metrics in victoria metrics, which we only have a bearer token for authentication, meaning we need to add header Authorization: Bearer xxx (rather than adding a username/password to the URL)
Maybe I'm missing something, but that doesn't see possible with this client (other than adding a custom round tripper and injecting headers, though the Go docs say RoundTrip should not modify the request)
It would be great to extend api.Config to support custom headers, such as:
// Config defines configuration parameters for a new client.
type Config struct {
// The address of the Prometheus to connect to.
Address string
// Headers contains custom HTTP request headers.
Headers map[string]string
// Client is used by the Client to drive HTTP requests. If not provided,
// a new one based on the provided RoundTripper (or DefaultRoundTripper) will be used.
Client *http.Client
// RoundTripper is used by the Client to drive HTTP requests. If not
// provided, DefaultRoundTripper will be used.
RoundTripper http.RoundTripper
}
I looked through open issues and PRs and couldn't see anything relating to this, though I'd be surprised if we were the first to run into this issue so sorry if this is a duplicate
The text was updated successfully, but these errors were encountered:
This is fairly easy to do thanks to ability to specify custom httpClient/transport or roundtripper, e.g. you can use NewHeadersRoundTripper from a common module to do so, or write a quick roundtripper yourself.
Does this help? (:
I will keep this issue open to add an example for this.
We're using the client to query metrics in victoria metrics, which we only have a bearer token for authentication, meaning we need to add header
Authorization: Bearer xxx
(rather than adding a username/password to the URL)Maybe I'm missing something, but that doesn't see possible with this client (other than adding a custom round tripper and injecting headers, though the Go docs say
RoundTrip should not modify the request
)It would be great to extend
api.Config
to support custom headers, such as:I looked through open issues and PRs and couldn't see anything relating to this, though I'd be surprised if we were the first to run into this issue so sorry if this is a duplicate
The text was updated successfully, but these errors were encountered: