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

Benchtool: add -bench.write.proxy-url argument. #223

Merged
merged 1 commit into from
Nov 16, 2021
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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`.
Expand Down
14 changes: 14 additions & 0 deletions pkg/bench/write_runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,15 @@ 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) {
f.BoolVar(&cfg.Enabled, "bench.write.enabled", false, "enable write benchmarking")
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 {
Expand Down Expand Up @@ -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),
Expand All @@ -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 {
Expand Down