Skip to content

Commit

Permalink
[coordinator] Add headers to along with request to remote write forwa…
Browse files Browse the repository at this point in the history
…rd target (#2249)
  • Loading branch information
robskillington authored Apr 4, 2020
1 parent af32eff commit 8f33747
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
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

0 comments on commit 8f33747

Please sign in to comment.