Skip to content

Commit

Permalink
add support for custom http request headers per servergroup
Browse files Browse the repository at this point in the history
  • Loading branch information
urgerestraint authored and jacksontj committed Apr 12, 2024
1 parent a9749c3 commit 35f7829
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
6 changes: 6 additions & 0 deletions pkg/servergroup/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,12 @@ type Config struct {
LabelFilterConfig *promclient.LabelFilterConfig `yaml:"label_filter"`

PreferMax bool `yaml:"prefer_max,omitempty"`

// HTTPClientHeaders are a map of HTTP headers to add to remote read HTTP calls made to this downstream
// the main use-case for this is to support the X-Scope-OrgID header required by Mimir and Cortex
// in multi-tenancy mode
// (see https://github.com/jacksontj/promxy/issues/643)
HTTPClientHeaders map[string]string `yaml:"http_headers"`
}

// GetScheme returns the scheme for this servergroup
Expand Down
4 changes: 4 additions & 0 deletions pkg/servergroup/servergroup.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,10 @@ func (s *ServerGroup) RoundTrip(r *http.Request) (*http.Response, error) {
for k, v := range middleware.GetHeaders(r.Context()) {
r.Header.Set(k, v)
}
for k, v := range s.Cfg.HTTPClientHeaders {
r.Header.Set(k, v)
logrus.Tracef("Set ServerGroup custom header %s: %s", k, v)
}
return s.client.Transport.RoundTrip(r)
}

Expand Down

0 comments on commit 35f7829

Please sign in to comment.