Compare commits

...

2 Commits

Author SHA1 Message Date
hagen1778
c1a938cf1a update flags
Signed-off-by: hagen1778 <roman@victoriametrics.com>
2025-10-02 15:02:26 +02:00
hagen1778
eb75135d0f app/vmalert: deliberately ignore --remoteRead.disablePathAppend for /query_range
Historically, `--remoteRead.disablePathAppend` has effect on datasource.url.
This setting disables adding `/api/v1/query` path to HTTP requests during rules evaluation.

Later, vmalert got support of rules backfilling. The backfilling issues HTTP requests to `/api/v1/query_range`
as optimization trick. But enabling `--remoteRead.disablePathAppend` effectively forbids adding `/api/v1/query_range`
path to requests. In result, queries to `/api/v1/query` and  `/api/v1/query_range` become indistinguishable.
This may lead to confusions like in https://github.com/VictoriaMetrics/VictoriaMetrics/issues/9779

This change ignores `--remoteRead.disablePathAppend` during backfilling with the following motivation:
1. There is no way backfilling could work if `--remoteRead.disablePathAppend` is set, because
/query and /query_range requests become indistinguishable.
2. If user's infrastructure doesn't expect /query_range path to be hit, vmalert error message
will highlight it right away. Instead of silently doing the wrong work as in https://github.com/VictoriaMetrics/VictoriaMetrics/issues/9779

Signed-off-by: hagen1778 <roman@victoriametrics.com>
2025-10-02 15:00:20 +02:00
5 changed files with 25 additions and 5 deletions

View File

@@ -249,9 +249,12 @@ func (c *Client) setPrometheusRangeReqParams(r *http.Request, query string, star
if c.appendTypePrefix {
r.URL.Path += "/prometheus"
}
if !*disablePathAppend {
r.URL.Path += "/api/v1/query_range"
}
// deliberately ignore *disablePathAppend
// if we don't append path, then newQueryRangeRequest and newQueryRequest will produce the same URL path and will become
// indistinguishable for remote datasource. This may lead to confusion as in https://github.com/VictoriaMetrics/VictoriaMetrics/issues/9779
r.URL.Path += "/api/v1/query_range"
q := r.URL.Query()
q.Add("start", start.Format(time.RFC3339))
q.Add("end", end.Format(time.RFC3339))

View File

@@ -566,6 +566,22 @@ func TestRequestParams(t *testing.T) {
checkEqualString(t, "/prometheus/api/v1/query_range", r.URL.Path)
})
// disable path append
*disablePathAppend = true
f(false, &Client{
dataSourceType: datasourcePrometheus,
}, func(t *testing.T, r *http.Request) {
checkEqualString(t, "", r.URL.Path)
})
f(true, &Client{
dataSourceType: datasourcePrometheus,
}, func(t *testing.T, r *http.Request) {
// path expected to be present despite *disablePathAppend setting
checkEqualString(t, "/api/v1/query_range", r.URL.Path)
})
*disablePathAppend = false
// graphite path
f(false, &Client{
dataSourceType: datasourceGraphite,

View File

@@ -15,7 +15,7 @@ import (
)
var (
addr = flag.String("datasource.url", "", "Datasource compatible with Prometheus HTTP API. It can be single node VictoriaMetrics or vmselect endpoint. Required parameter. "+
addr = flag.String("datasource.url", "", "Datasource compatible with Prometheus or VictoriaLogs HTTP API. It can be single node VictoriaMetrics, vmselect or VictoriaLogs endpoint. Required parameter. "+
"Supports address in the form of IP address with a port (e.g., http://127.0.0.1:8428) or DNS SRV record. "+
"See also -remoteRead.disablePathAppend and -datasource.showURL")
appendTypePrefix = flag.Bool("datasource.appendTypePrefix", false, "Whether to add type prefix to -datasource.url based on the query type. Set to true if sending different query types to the vmselect URL.")

View File

@@ -29,6 +29,7 @@ See also [LTS releases](https://docs.victoriametrics.com/victoriametrics/lts-rel
* SECURITY: upgrade Go builder from Go1.25.0 to Go1.25.1. See [the list of issues addressed in Go1.25.1](https://github.com/golang/go/issues?q=milestone%3AGo1.25.1%20label%3ACherryPickApproved).
* FEATURE: [vmalert](https://docs.victoriametrics.com/victoriametrics/vmalert/): add `-rule.resultsLimit` command-line flag to allow limiting the number of alerts or recording results a single rule can produce. See [#5792](https://github.com/VictoriaMetrics/VictoriaMetrics/issues/5792).
* FEATURE: [vmalert](https://docs.victoriametrics.com/victoriametrics/vmalert/): ignore `-remoteRead.disablePathAppend` setting during [rules backfilling](https://docs.victoriametrics.com/victoriametrics/vmalert/#rules-backfilling). See [#9779](https://github.com/VictoriaMetrics/VictoriaMetrics/issues/9779).
* FEATURE: [vmauth](https://docs.victoriametrics.com/victoriametrics/vmauth/): stream responses from backends to clients without delays. Previously the backend data could be buffered at `vmauth` side for indefinite amounts of time. This was preventing from using `vmauth` for streaming the data from backends in [live tailing mode](https://docs.victoriametrics.com/victorialogs/querying/#live-tailing). See [VictoriaLogs#667](https://github.com/VictoriaMetrics/VictoriaLogs/issues/667).
* FEATURE: [vmbackup](https://docs.victoriametrics.com/victoriametrics/vmbackup/), [vmrestore](https://docs.victoriametrics.com/victoriametrics/vmrestore/): push metrics to configured `-pushmetrics.url` on shutdown. Before, if `-pushmetrics.url` was configured, vmbackup or vmrestore might have skipped to report their metrics before shutdown.
* FEATURE: [dashboards/operator](https://github.com/VictoriaMetrics/VictoriaMetrics/blob/master/dashboards/operator.json), [dashboards/query-stats](https://github.com/VictoriaMetrics/VictoriaMetrics/blob/master/dashboards/query-stats.json): add ad-hoc filters.

View File

@@ -70,7 +70,7 @@ See the docs at https://docs.victoriametrics.com/victoriametrics/vmalert/ .
-datasource.tlsServerName string
Optional TLS server name to use for connections to -datasource.url. By default, the server name from -datasource.url is used
-datasource.url string
Datasource compatible with Prometheus HTTP API. It can be single node VictoriaMetrics or vmselect endpoint. Required parameter. Supports address in the form of IP address with a port (e.g., http://127.0.0.1:8428) or DNS SRV record. See also -remoteRead.disablePathAppend and -datasource.showURL
Datasource compatible with Prometheus or VictoriaLogs HTTP API. It can be single node VictoriaMetrics, vmselect or VictoriaLogs endpoint. Required parameter. Supports address in the form of IP address with a port (e.g., http://127.0.0.1:8428) or DNS SRV record. See also -remoteRead.disablePathAppend and -datasource.showURL
-defaultTenant.graphite string
Default tenant for Graphite alerting groups. See https://docs.victoriametrics.com/victoriametrics/vmalert/#multitenancy .This flag is available only in Enterprise binaries. See https://docs.victoriametrics.com/victoriametrics/enterprise/
-defaultTenant.prometheus string