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

[coordinator] Add headers to along with request to remote write forward target #2249

Merged
merged 2 commits into from
Apr 4, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/query/api/v1/handler/prometheus/handleroptions/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,6 @@ type PromWriteHandlerForwardTargetOptions struct {
URL string `yaml:"url"`
// Method defaults to POST if not set.
Method string `yaml:"method"`
// Headers to send along with requests to the target.
Headers map[string]string `yaml:"headers"`
}
7 changes: 7 additions & 0 deletions src/query/api/v1/handler/prometheus/remote/write.go
Original file line number Diff line number Diff line change
Expand Up @@ -425,6 +425,13 @@ func (h *PromWriteHandler) forward(
return err
}

if headers := target.Headers; headers != nil {
// If headers set, attach to request.
for name, value := range headers {
req.Header.Add(name, value)
}
}

resp, err := h.forwardHTTPClient.Do(req.WithContext(ctx))
if err != nil {
return err
Expand Down