diff --git a/CHANGELOG.md b/CHANGELOG.md index 110dac9ba..df5e7abf1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ Order should be `CHANGE`, `FEATURE`, `ENHANCEMENT`, and `BUGFIX` +## unreleased + +* [ENHANCEMENT] Benchtool: add `-bench.write.proxy-url` argument for configuring the Prometheus remote-write client with a HTTP proxy URL. #223 + ## v0.10.6 * [FEATURE] Rules check for Loki now supports `pattern`. diff --git a/pkg/bench/write_runner.go b/pkg/bench/write_runner.go index 5abdbdeec..480e21cf5 100644 --- a/pkg/bench/write_runner.go +++ b/pkg/bench/write_runner.go @@ -29,6 +29,7 @@ type WriteBenchConfig struct { Endpoint string `yaml:"endpoint"` BasicAuthUsername string `yaml:"basic_auth_username"` BasicAuthPasword string `yaml:"basic_auth_password"` + ProxyURL string `yaml:"proxy_url"` } func (cfg *WriteBenchConfig) RegisterFlags(f *flag.FlagSet) { @@ -36,6 +37,7 @@ func (cfg *WriteBenchConfig) RegisterFlags(f *flag.FlagSet) { f.StringVar(&cfg.Endpoint, "bench.write.endpoint", "", "Remote write endpoint.") f.StringVar(&cfg.BasicAuthUsername, "bench.write.basic-auth-username", "", "Set the basic auth username on remote write requests.") f.StringVar(&cfg.BasicAuthPasword, "bench.write.basic-auth-password", "", "Set the basic auth password on remote write requests.") + f.StringVar(&cfg.ProxyURL, "bench.write.proxy-url", "", "Set the HTTP proxy URL to use on remote write requests.") } type WriteBenchmarkRunner struct { @@ -110,6 +112,15 @@ func (w *WriteBenchmarkRunner) getRandomWriteClient() (*writeClient, error) { if err != nil { return nil, err } + + var proxyURL *url.URL + if w.cfg.ProxyURL != "" { + proxyURL, err = url.Parse(w.cfg.ProxyURL) + if err != nil { + return nil, errors.Wrap(err, "invalid proxy url") + } + } + cli, err = newWriteClient("bench-"+pick, w.tenantName, &remote.ClientConfig{ URL: &config.URL{URL: u}, Timeout: model.Duration(w.workload.options.Timeout), @@ -119,6 +130,9 @@ func (w *WriteBenchmarkRunner) getRandomWriteClient() (*writeClient, error) { Username: w.cfg.BasicAuthUsername, Password: config.Secret(w.cfg.BasicAuthPasword), }, + ProxyURL: config.URL{ + URL: proxyURL, + }, }, }, w.logger, w.requestDuration) if err != nil {