mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2025-03-11 15:34:56 +00:00
app/vmctl: Allow vmnative exports to skip HTTP keepalive. (#3909)
app/vmctl: support HTTP keepalive disabling for vm-native mode
This commit is contained in:
parent
cbba6bd3db
commit
09e3742a82
3 changed files with 26 additions and 15 deletions
|
@ -325,6 +325,8 @@ const (
|
||||||
vmNativeFilterTimeEnd = "vm-native-filter-time-end"
|
vmNativeFilterTimeEnd = "vm-native-filter-time-end"
|
||||||
vmNativeStepInterval = "vm-native-step-interval"
|
vmNativeStepInterval = "vm-native-step-interval"
|
||||||
|
|
||||||
|
vmNativeDisableHTTPKeepAlive = "vm-native-disable-http-keep-alive"
|
||||||
|
|
||||||
vmNativeSrcAddr = "vm-native-src-addr"
|
vmNativeSrcAddr = "vm-native-src-addr"
|
||||||
vmNativeSrcUser = "vm-native-src-user"
|
vmNativeSrcUser = "vm-native-src-user"
|
||||||
vmNativeSrcPassword = "vm-native-src-password"
|
vmNativeSrcPassword = "vm-native-src-password"
|
||||||
|
@ -358,6 +360,11 @@ var (
|
||||||
Name: vmNativeStepInterval,
|
Name: vmNativeStepInterval,
|
||||||
Usage: fmt.Sprintf("Split export data into chunks. Requires setting --%s. Valid values are '%s','%s','%s','%s'.", vmNativeFilterTimeStart, stepper.StepMonth, stepper.StepDay, stepper.StepHour, stepper.StepMinute),
|
Usage: fmt.Sprintf("Split export data into chunks. Requires setting --%s. Valid values are '%s','%s','%s','%s'.", vmNativeFilterTimeStart, stepper.StepMonth, stepper.StepDay, stepper.StepHour, stepper.StepMinute),
|
||||||
},
|
},
|
||||||
|
&cli.BoolFlag{
|
||||||
|
Name: vmNativeDisableHTTPKeepAlive,
|
||||||
|
Usage: "Disable HTTP persistent connections for requests made to VictoriaMetrics components during export",
|
||||||
|
Value: false,
|
||||||
|
},
|
||||||
&cli.StringFlag{
|
&cli.StringFlag{
|
||||||
Name: vmNativeSrcAddr,
|
Name: vmNativeSrcAddr,
|
||||||
Usage: "VictoriaMetrics address to perform export from. \n" +
|
Usage: "VictoriaMetrics address to perform export from. \n" +
|
||||||
|
|
|
@ -209,17 +209,19 @@ func main() {
|
||||||
Chunk: c.String(vmNativeStepInterval),
|
Chunk: c.String(vmNativeStepInterval),
|
||||||
},
|
},
|
||||||
src: &native.Client{
|
src: &native.Client{
|
||||||
Addr: strings.Trim(c.String(vmNativeSrcAddr), "/"),
|
Addr: strings.Trim(c.String(vmNativeSrcAddr), "/"),
|
||||||
User: c.String(vmNativeSrcUser),
|
User: c.String(vmNativeSrcUser),
|
||||||
Password: c.String(vmNativeSrcPassword),
|
Password: c.String(vmNativeSrcPassword),
|
||||||
Headers: c.String(vmNativeSrcHeaders),
|
Headers: c.String(vmNativeSrcHeaders),
|
||||||
|
DisableHTTPKeepAlive: c.Bool(vmNativeDisableHTTPKeepAlive),
|
||||||
},
|
},
|
||||||
dst: &native.Client{
|
dst: &native.Client{
|
||||||
Addr: strings.Trim(c.String(vmNativeDstAddr), "/"),
|
Addr: strings.Trim(c.String(vmNativeDstAddr), "/"),
|
||||||
User: c.String(vmNativeDstUser),
|
User: c.String(vmNativeDstUser),
|
||||||
Password: c.String(vmNativeDstPassword),
|
Password: c.String(vmNativeDstPassword),
|
||||||
ExtraLabels: c.StringSlice(vmExtraLabel),
|
ExtraLabels: c.StringSlice(vmExtraLabel),
|
||||||
Headers: c.String(vmNativeDstHeaders),
|
Headers: c.String(vmNativeDstHeaders),
|
||||||
|
DisableHTTPKeepAlive: c.Bool(vmNativeDisableHTTPKeepAlive),
|
||||||
},
|
},
|
||||||
backoff: backoff.New(),
|
backoff: backoff.New(),
|
||||||
cc: c.Int(vmConcurrency),
|
cc: c.Int(vmConcurrency),
|
||||||
|
|
|
@ -18,11 +18,12 @@ const (
|
||||||
// Client is an HTTP client for exporting and importing
|
// Client is an HTTP client for exporting and importing
|
||||||
// time series via native protocol.
|
// time series via native protocol.
|
||||||
type Client struct {
|
type Client struct {
|
||||||
Addr string
|
Addr string
|
||||||
User string
|
User string
|
||||||
Password string
|
Password string
|
||||||
ExtraLabels []string
|
ExtraLabels []string
|
||||||
Headers string
|
Headers string
|
||||||
|
DisableHTTPKeepAlive bool
|
||||||
}
|
}
|
||||||
|
|
||||||
// LabelValues represents series from api/v1/series response
|
// LabelValues represents series from api/v1/series response
|
||||||
|
@ -196,7 +197,8 @@ func (c *Client) do(req *http.Request, expSC int) (*http.Response, error) {
|
||||||
if c.User != "" {
|
if c.User != "" {
|
||||||
req.SetBasicAuth(c.User, c.Password)
|
req.SetBasicAuth(c.User, c.Password)
|
||||||
}
|
}
|
||||||
resp, err := http.DefaultClient.Do(req)
|
var httpClient = &http.Client{Transport: &http.Transport{DisableKeepAlives: c.DisableHTTPKeepAlive}}
|
||||||
|
resp, err := httpClient.Do(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("unexpected error when performing request: %w", err)
|
return nil, fmt.Errorf("unexpected error when performing request: %w", err)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue