diff --git a/app/vmselect/promql/exec_test.go b/app/vmselect/promql/exec_test.go index 3290612a7..d7c01c666 100644 --- a/app/vmselect/promql/exec_test.go +++ b/app/vmselect/promql/exec_test.go @@ -7669,7 +7669,7 @@ func TestExecSuccess(t *testing.T) { }) t.Run(`aggr_over_time(multi-func)`, func(t *testing.T) { t.Parallel() - q := `sort(aggr_over_time(("min_over_time", "count_over_time", "max_over_time"), round(rand(0),0.1)[:10s]))` + q := `sort(aggr_over_time(("min_over_time", "median_over_time", "max_over_time"), round(rand(0),0.1)[:10s]))` r1 := netstorage.Result{ MetricName: metricNameExpected, Values: []float64{0, 0, 0, 0, 0, 0}, @@ -7681,21 +7681,21 @@ func TestExecSuccess(t *testing.T) { }} r2 := netstorage.Result{ MetricName: metricNameExpected, - Values: []float64{0.8, 0.9, 1, 0.9, 1, 0.9}, + Values: []float64{0.4, 0.5, 0.5, 0.75, 0.6, 0.45}, Timestamps: timestampsExpected, } r2.MetricName.Tags = []storage.Tag{{ Key: []byte("rollup"), - Value: []byte("max_over_time"), + Value: []byte("median_over_time"), }} r3 := netstorage.Result{ MetricName: metricNameExpected, - Values: []float64{20, 20, 20, 20, 20, 20}, + Values: []float64{0.8, 0.9, 1, 0.9, 1, 0.9}, Timestamps: timestampsExpected, } r3.MetricName.Tags = []storage.Tag{{ Key: []byte("rollup"), - Value: []byte("count_over_time"), + Value: []byte("max_over_time"), }} resultExpected := []netstorage.Result{r1, r2, r3} f(q, resultExpected) diff --git a/app/vmselect/promql/rollup.go b/app/vmselect/promql/rollup.go index cfbc03055..9f84f74a7 100644 --- a/app/vmselect/promql/rollup.go +++ b/app/vmselect/promql/rollup.go @@ -59,6 +59,7 @@ var rollupFuncs = map[string]newRollupFunc{ "lifetime": newRollupFuncOneArg(rollupLifetime), "mad_over_time": newRollupFuncOneArg(rollupMAD), "max_over_time": newRollupFuncOneArg(rollupMax), + "median_over_time": newRollupFuncOneArg(rollupMedian), "min_over_time": newRollupFuncOneArg(rollupMin), "mode_over_time": newRollupFuncOneArg(rollupModeOverTime), "predict_linear": newRollupPredictLinear, @@ -226,6 +227,7 @@ var rollupFuncsKeepMetricName = map[string]bool{ "holt_winters": true, "last_over_time": true, "max_over_time": true, + "median_over_time": true, "min_over_time": true, "mode_over_time": true, "predict_linear": true, diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index eec787fa7..0a2b2b9f2 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -55,7 +55,7 @@ The sandbox cluster installation is running under the constant load generated by * BUGFIX: [VictoriaMetrics enterprise](https://docs.victoriametrics.com/enterprise.html) validate `-dedup.minScrapeInterval` value and `-downsampling.period` intervals are multiples of each other. See [these docs](https://docs.victoriametrics.com/#downsampling). * BUGFIX: [vmbackup](https://docs.victoriametrics.com/vmbackup.html): properly copy `appliedRetention.txt` files inside `<-storageDataPath>/{data}` folders during [incremental backups](https://docs.victoriametrics.com/vmbackup.html#incremental-backups). Previously the new `appliedRetention.txt` could be skipped during incremental backups, which could lead to increased load on storage after restoring from backup. See [this issue](https://github.com/VictoriaMetrics/VictoriaMetrics/issues/5005). * BUGFIX: [vmagent](https://docs.victoriametrics.com/vmagent.html): suppress `context canceled` error messages in logs when `vmagent` is reloading service discovery config. This error could appear starting from [v1.93.5](https://github.com/VictoriaMetrics/VictoriaMetrics/releases/tag/v1.93.5). See [this PR](https://github.com/VictoriaMetrics/VictoriaMetrics/pull/5048). -* BUGFIX: [MetricsQL](https://docs.victoriametrics.com/MetricsQL.html): allow using `median_over_time` in [`aggr_over_time`](https://docs.victoriametrics.com/MetricsQL.html#aggr_over_time) [rollup function](https://docs.victoriametrics.com/MetricsQL.html#rollup-functions). See [this issue](https://github.com/VictoriaMetrics/VictoriaMetrics/issues/5034). +* BUGFIX: [MetricsQL](https://docs.victoriametrics.com/MetricsQL.html): allow passing [median_over_time](https://docs.victoriametrics.com/MetricsQL.html#median_over_time) to [aggr_over_time](https://docs.victoriametrics.com/MetricsQL.html#aggr_over_time). See [this issue](https://github.com/VictoriaMetrics/VictoriaMetrics/issues/5034). ## [v1.93.5](https://github.com/VictoriaMetrics/VictoriaMetrics/releases/tag/v1.93.5) diff --git a/go.mod b/go.mod index a6ee13e10..6d1a47169 100644 --- a/go.mod +++ b/go.mod @@ -12,7 +12,7 @@ require ( // like https://github.com/valyala/fasthttp/commit/996610f021ff45fdc98c2ce7884d5fa4e7f9199b github.com/VictoriaMetrics/fasthttp v1.2.0 github.com/VictoriaMetrics/metrics v1.24.0 - github.com/VictoriaMetrics/metricsql v0.65.0 + github.com/VictoriaMetrics/metricsql v0.66.0 github.com/aws/aws-sdk-go-v2 v1.21.0 github.com/aws/aws-sdk-go-v2/config v1.18.39 github.com/aws/aws-sdk-go-v2/feature/s3/manager v1.11.83 diff --git a/go.sum b/go.sum index 9bfe01c62..aebec4c96 100644 --- a/go.sum +++ b/go.sum @@ -70,8 +70,8 @@ github.com/VictoriaMetrics/fasthttp v1.2.0 h1:nd9Wng4DlNtaI27WlYh5mGXCJOmee/2c2b github.com/VictoriaMetrics/fasthttp v1.2.0/go.mod h1:zv5YSmasAoSyv8sBVexfArzFDIGGTN4TfCKAtAw7IfE= github.com/VictoriaMetrics/metrics v1.24.0 h1:ILavebReOjYctAGY5QU2F9X0MYvkcrG3aEn2RKa1Zkw= github.com/VictoriaMetrics/metrics v1.24.0/go.mod h1:eFT25kvsTidQFHb6U0oa0rTrDRdz4xTYjpL8+UPohys= -github.com/VictoriaMetrics/metricsql v0.65.0 h1:+/Oit3QycM8z/NbMHy4KENSUDS5q9QRx8h2x6cvoQOk= -github.com/VictoriaMetrics/metricsql v0.65.0/go.mod h1:k4UaP/+CjuZslIjd+kCigNG9TQmUqh5v0TP/nMEy90I= +github.com/VictoriaMetrics/metricsql v0.66.0 h1:2TaBEM7L5L67Ho65FdJVZ/qvjWmC/+f17nujL6dgtmE= +github.com/VictoriaMetrics/metricsql v0.66.0/go.mod h1:k4UaP/+CjuZslIjd+kCigNG9TQmUqh5v0TP/nMEy90I= github.com/VividCortex/ewma v1.2.0 h1:f58SaIzcDXrSy3kWaHNvuJgJ3Nmz59Zji6XoJR/q1ow= github.com/VividCortex/ewma v1.2.0/go.mod h1:nz4BbCtbLyFDeC9SUHbtcT5644juEuWfUAUnGx7j5l4= github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= diff --git a/vendor/github.com/VictoriaMetrics/metricsql/parser.go b/vendor/github.com/VictoriaMetrics/metricsql/parser.go index c40876857..8458e5f71 100644 --- a/vendor/github.com/VictoriaMetrics/metricsql/parser.go +++ b/vendor/github.com/VictoriaMetrics/metricsql/parser.go @@ -55,7 +55,6 @@ func getDefaultWithArgExprs() []*withArgExpr { clamp_max(step()/300, 1) )`, - `median_over_time(m) = quantile_over_time(0.5, m)`, `range_median(q) = range_quantile(0.5, q)`, `alias(q, name) = label_set(q, "__name__", name)`, }) diff --git a/vendor/github.com/VictoriaMetrics/metricsql/rollup.go b/vendor/github.com/VictoriaMetrics/metricsql/rollup.go index da3204adc..99d8f56bc 100644 --- a/vendor/github.com/VictoriaMetrics/metricsql/rollup.go +++ b/vendor/github.com/VictoriaMetrics/metricsql/rollup.go @@ -44,6 +44,7 @@ var rollupFuncs = map[string]bool{ "lifetime": true, "mad_over_time": true, "max_over_time": true, + "median_over_time": true, "min_over_time": true, "mode_over_time": true, "predict_linear": true, diff --git a/vendor/modules.txt b/vendor/modules.txt index 7c406cb47..37d0db292 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -99,7 +99,7 @@ github.com/VictoriaMetrics/fasthttp/stackless # github.com/VictoriaMetrics/metrics v1.24.0 ## explicit; go 1.20 github.com/VictoriaMetrics/metrics -# github.com/VictoriaMetrics/metricsql v0.65.0 +# github.com/VictoriaMetrics/metricsql v0.66.0 ## explicit; go 1.13 github.com/VictoriaMetrics/metricsql github.com/VictoriaMetrics/metricsql/binaryop