mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-11-21 14:44:00 +00:00
app/vmagent: fix panic if auth config not defined (#530)
This commit is contained in:
parent
202083f38c
commit
66bf1987bf
1 changed files with 7 additions and 2 deletions
|
@ -151,12 +151,15 @@ func newHTTPClient(argIdx int, remoteWriteURL, sanitizedURL string, fq *persiste
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *client) init(argIdx, concurrency int, sanitizedURL string) {
|
func (c *client) init(argIdx, concurrency int, sanitizedURL string) {
|
||||||
|
// custom proto encoding is supported only over http connections
|
||||||
|
isHTTPClient := c.hc != nil
|
||||||
|
|
||||||
useVMProto := forceVMProto.GetOptionalArg(argIdx)
|
useVMProto := forceVMProto.GetOptionalArg(argIdx)
|
||||||
usePromProto := forcePromProto.GetOptionalArg(argIdx)
|
usePromProto := forcePromProto.GetOptionalArg(argIdx)
|
||||||
if useVMProto && usePromProto {
|
if useVMProto && usePromProto {
|
||||||
logger.Fatalf("-remoteWrite.useVMProto and -remoteWrite.usePromProto cannot be set simultaneously for -remoteWrite.url=%s", sanitizedURL)
|
logger.Fatalf("-remoteWrite.useVMProto and -remoteWrite.usePromProto cannot be set simultaneously for -remoteWrite.url=%s", sanitizedURL)
|
||||||
}
|
}
|
||||||
if !useVMProto && !usePromProto {
|
if isHTTPClient && !useVMProto && !usePromProto {
|
||||||
// Auto-detect whether the remote storage supports VictoriaMetrics remote write protocol.
|
// Auto-detect whether the remote storage supports VictoriaMetrics remote write protocol.
|
||||||
doRequest := func(url string) (*http.Response, error) {
|
doRequest := func(url string) (*http.Response, error) {
|
||||||
return c.doRequest(url, nil)
|
return c.doRequest(url, nil)
|
||||||
|
@ -167,7 +170,9 @@ func (c *client) init(argIdx, concurrency int, sanitizedURL string) {
|
||||||
"See https://docs.victoriametrics.com/vmagent.html#victoriametrics-remote-write-protocol", sanitizedURL)
|
"See https://docs.victoriametrics.com/vmagent.html#victoriametrics-remote-write-protocol", sanitizedURL)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
c.useVMProto = useVMProto
|
if isHTTPClient {
|
||||||
|
c.useVMProto = useVMProto
|
||||||
|
}
|
||||||
|
|
||||||
if bytesPerSec := rateLimit.GetOptionalArgOrDefault(argIdx, 0); bytesPerSec > 0 {
|
if bytesPerSec := rateLimit.GetOptionalArgOrDefault(argIdx, 0); bytesPerSec > 0 {
|
||||||
logger.Infof("applying %d bytes per second rate limit for -remoteWrite.url=%q", bytesPerSec, sanitizedURL)
|
logger.Infof("applying %d bytes per second rate limit for -remoteWrite.url=%q", bytesPerSec, sanitizedURL)
|
||||||
|
|
Loading…
Reference in a new issue