mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2025-03-21 15:45:01 +00:00
vmalert: enable configuring explicit path (#1536)
* vmalert: allow to disable automatically added path to remote write address via disablePathAppend flag * docs: update docs to include remoteWrite.disablePathAppend
This commit is contained in:
parent
9af8c71975
commit
2400f85761
4 changed files with 68 additions and 56 deletions
|
@ -502,6 +502,8 @@ The shortlist of configuration flags is the following:
|
||||||
Optional TLS server name to use for connections to -remoteWrite.url. By default the server name from -remoteWrite.url is used
|
Optional TLS server name to use for connections to -remoteWrite.url. By default the server name from -remoteWrite.url is used
|
||||||
-remoteWrite.url string
|
-remoteWrite.url string
|
||||||
Optional URL to VictoriaMetrics or vminsert where to persist alerts state and recording rules results in form of timeseries. E.g. http://127.0.0.1:8428
|
Optional URL to VictoriaMetrics or vminsert where to persist alerts state and recording rules results in form of timeseries. E.g. http://127.0.0.1:8428
|
||||||
|
-remoteWrite.disablePathAppend
|
||||||
|
Whether to disable automatic appending of '/api/v1/write' path to the configured -remoteWrite.url.
|
||||||
-replay.maxDatapointsPerQuery int
|
-replay.maxDatapointsPerQuery int
|
||||||
Max number of data points expected in one request. The higher the value, the less requests will be made during replay. (default 1000)
|
Max number of data points expected in one request. The higher the value, the less requests will be made during replay. (default 1000)
|
||||||
-replay.ruleRetryAttempts int
|
-replay.ruleRetryAttempts int
|
||||||
|
|
|
@ -27,6 +27,7 @@ var (
|
||||||
"By default system CA is used")
|
"By default system CA is used")
|
||||||
tlsServerName = flag.String("remoteWrite.tlsServerName", "", "Optional TLS server name to use for connections to -remoteWrite.url. "+
|
tlsServerName = flag.String("remoteWrite.tlsServerName", "", "Optional TLS server name to use for connections to -remoteWrite.url. "+
|
||||||
"By default the server name from -remoteWrite.url is used")
|
"By default the server name from -remoteWrite.url is used")
|
||||||
|
disablePathAppend = flag.Bool("remoteWrite.disablePathAppend", false, "Whether to disable automatic appending of '/api/v1/write' path to the configured -remoteWrite.url.")
|
||||||
)
|
)
|
||||||
|
|
||||||
// Init creates Client object from given flags.
|
// Init creates Client object from given flags.
|
||||||
|
@ -49,6 +50,7 @@ func Init(ctx context.Context) (*Client, error) {
|
||||||
FlushInterval: *flushInterval,
|
FlushInterval: *flushInterval,
|
||||||
BasicAuthUser: *basicAuthUsername,
|
BasicAuthUser: *basicAuthUsername,
|
||||||
BasicAuthPass: *basicAuthPassword,
|
BasicAuthPass: *basicAuthPassword,
|
||||||
|
DisablePathAppend: *disablePathAppend,
|
||||||
Transport: t,
|
Transport: t,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,6 +26,7 @@ type Client struct {
|
||||||
flushInterval time.Duration
|
flushInterval time.Duration
|
||||||
maxBatchSize int
|
maxBatchSize int
|
||||||
maxQueueSize int
|
maxQueueSize int
|
||||||
|
disablePathAppend bool
|
||||||
|
|
||||||
wg sync.WaitGroup
|
wg sync.WaitGroup
|
||||||
doneCh chan struct{}
|
doneCh chan struct{}
|
||||||
|
@ -56,6 +57,8 @@ type Config struct {
|
||||||
WriteTimeout time.Duration
|
WriteTimeout time.Duration
|
||||||
// Transport will be used by the underlying http.Client
|
// Transport will be used by the underlying http.Client
|
||||||
Transport *http.Transport
|
Transport *http.Transport
|
||||||
|
// DisablePathAppend can be used to not automatically append '/api/v1/write' to the remote write url
|
||||||
|
DisablePathAppend bool
|
||||||
}
|
}
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
@ -102,6 +105,7 @@ func NewClient(ctx context.Context, cfg Config) (*Client, error) {
|
||||||
maxQueueSize: cfg.MaxQueueSize,
|
maxQueueSize: cfg.MaxQueueSize,
|
||||||
doneCh: make(chan struct{}),
|
doneCh: make(chan struct{}),
|
||||||
input: make(chan prompbmarshal.TimeSeries, cfg.MaxQueueSize),
|
input: make(chan prompbmarshal.TimeSeries, cfg.MaxQueueSize),
|
||||||
|
disablePathAppend: cfg.DisablePathAppend,
|
||||||
}
|
}
|
||||||
cc := defaultConcurrency
|
cc := defaultConcurrency
|
||||||
if cfg.Concurrency > 0 {
|
if cfg.Concurrency > 0 {
|
||||||
|
@ -231,7 +235,9 @@ func (c *Client) send(ctx context.Context, data []byte) error {
|
||||||
if c.baPass != "" {
|
if c.baPass != "" {
|
||||||
req.SetBasicAuth(c.baUser, c.baPass)
|
req.SetBasicAuth(c.baUser, c.baPass)
|
||||||
}
|
}
|
||||||
|
if !c.disablePathAppend {
|
||||||
req.URL.Path += writePath
|
req.URL.Path += writePath
|
||||||
|
}
|
||||||
resp, err := c.c.Do(req.WithContext(ctx))
|
resp, err := c.c.Do(req.WithContext(ctx))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("error while sending request to %s: %w; Data len %d(%d)",
|
return fmt.Errorf("error while sending request to %s: %w; Data len %d(%d)",
|
||||||
|
|
|
@ -506,6 +506,8 @@ The shortlist of configuration flags is the following:
|
||||||
Optional TLS server name to use for connections to -remoteWrite.url. By default the server name from -remoteWrite.url is used
|
Optional TLS server name to use for connections to -remoteWrite.url. By default the server name from -remoteWrite.url is used
|
||||||
-remoteWrite.url string
|
-remoteWrite.url string
|
||||||
Optional URL to VictoriaMetrics or vminsert where to persist alerts state and recording rules results in form of timeseries. E.g. http://127.0.0.1:8428
|
Optional URL to VictoriaMetrics or vminsert where to persist alerts state and recording rules results in form of timeseries. E.g. http://127.0.0.1:8428
|
||||||
|
-remoteWrite.disablePathAppend
|
||||||
|
Whether to disable automatic appending of '/api/v1/write' path to the configured -remoteWrite.url.
|
||||||
-replay.maxDatapointsPerQuery int
|
-replay.maxDatapointsPerQuery int
|
||||||
Max number of data points expected in one request. The higher the value, the less requests will be made during replay. (default 1000)
|
Max number of data points expected in one request. The higher the value, the less requests will be made during replay. (default 1000)
|
||||||
-replay.ruleRetryAttempts int
|
-replay.ruleRetryAttempts int
|
||||||
|
|
Loading…
Reference in a new issue