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

Add flag to send request to another endpoint instead of the FQDN #102

Closed
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
18 changes: 12 additions & 6 deletions cmd/client/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,13 @@ import (
)

var (
myFqdn = kingpin.Flag("fqdn", "FQDN to register with").Default(fqdn.Get()).String()
proxyURL = kingpin.Flag("proxy-url", "Push proxy to talk to.").Required().String()
caCertFile = kingpin.Flag("tls.cacert", "<file> CA certificate to verify peer against").String()
tlsCert = kingpin.Flag("tls.cert", "<cert> Client certificate file").String()
tlsKey = kingpin.Flag("tls.key", "<key> Private key file").String()
metricsAddr = kingpin.Flag("metrics-addr", "Serve Prometheus metrics at this address").Default(":9369").String()
myFqdn = kingpin.Flag("fqdn", "FQDN to register with").Default(fqdn.Get()).String()
proxyURL = kingpin.Flag("proxy-url", "Push proxy to talk to.").Required().String()
caCertFile = kingpin.Flag("tls.cacert", "<file> CA certificate to verify peer against").String()
tlsCert = kingpin.Flag("tls.cert", "<cert> Client certificate file").String()
tlsKey = kingpin.Flag("tls.key", "<key> Private key file").String()
metricsAddr = kingpin.Flag("metrics-addr", "Serve Prometheus metrics at this address").Default(":9369").String()
internalEndpoint = kingpin.Flag("internal-endpoint", "If set, requests will be forwarded to this endpoint").String()

retryInitialWait = kingpin.Flag("proxy.retry.initial-wait", "Amount of time to wait after proxy failure").Default("1s").Duration()
retryMaxWait = kingpin.Flag("proxy.retry.max-wait", "Maximum amount of time to wait between proxy poll retries").Default("5s").Duration()
Expand Down Expand Up @@ -133,6 +134,11 @@ func (c *Coordinator) doScrape(request *http.Request, client *http.Client) {
return
}

if *internalEndpoint != "" {
newHost := fmt.Sprintf("%s:%s", *internalEndpoint, request.URL.Port())
request.URL.Host = newHost
}

scrapeResp, err := client.Do(request)
if err != nil {
msg := fmt.Sprintf("failed to scrape %s", request.URL.String())
Expand Down