From 9b07cb298869f80f3eaafff6f35decd896a21d68 Mon Sep 17 00:00:00 2001 From: Aliaksandr Valialkin Date: Thu, 9 Sep 2021 19:21:16 +0300 Subject: [PATCH] app/vmselect/promql: keep metric name in `rollup_candlestick` results, since they don't change the original series meaning Updates https://github.com/VictoriaMetrics/VictoriaMetrics/issues/1600 --- app/vmselect/promql/exec_test.go | 6 +++++- app/vmselect/promql/rollup.go | 1 + docs/CHANGELOG.md | 1 + 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/app/vmselect/promql/exec_test.go b/app/vmselect/promql/exec_test.go index 88d7a11ae..5ffb6fada 100644 --- a/app/vmselect/promql/exec_test.go +++ b/app/vmselect/promql/exec_test.go @@ -6252,12 +6252,13 @@ func TestExecSuccess(t *testing.T) { }) t.Run(`rollup_candlestick()`, func(t *testing.T) { t.Parallel() - q := `sort(rollup_candlestick(round(rand(0),0.01)[:10s]))` + q := `sort(rollup_candlestick(alias(round(rand(0),0.01),"foobar")[:10s]))` r1 := netstorage.Result{ MetricName: metricNameExpected, Values: []float64{0.02, 0.02, 0.03, 0, 0.03, 0.02}, Timestamps: timestampsExpected, } + r1.MetricName.MetricGroup = []byte("foobar") r1.MetricName.Tags = []storage.Tag{{ Key: []byte("rollup"), Value: []byte("low"), @@ -6267,6 +6268,7 @@ func TestExecSuccess(t *testing.T) { Values: []float64{0.9, 0.32, 0.82, 0.13, 0.28, 0.86}, Timestamps: timestampsExpected, } + r2.MetricName.MetricGroup = []byte("foobar") r2.MetricName.Tags = []storage.Tag{{ Key: []byte("rollup"), Value: []byte("open"), @@ -6276,6 +6278,7 @@ func TestExecSuccess(t *testing.T) { Values: []float64{0.1, 0.04, 0.49, 0.46, 0.57, 0.92}, Timestamps: timestampsExpected, } + r3.MetricName.MetricGroup = []byte("foobar") r3.MetricName.Tags = []storage.Tag{{ Key: []byte("rollup"), Value: []byte("close"), @@ -6285,6 +6288,7 @@ func TestExecSuccess(t *testing.T) { Values: []float64{0.9, 0.94, 0.97, 0.93, 0.98, 0.92}, Timestamps: timestampsExpected, } + r4.MetricName.MetricGroup = []byte("foobar") r4.MetricName.Tags = []storage.Tag{{ Key: []byte("rollup"), Value: []byte("high"), diff --git a/app/vmselect/promql/rollup.go b/app/vmselect/promql/rollup.go index cdac2b208..aaeb95bc9 100644 --- a/app/vmselect/promql/rollup.go +++ b/app/vmselect/promql/rollup.go @@ -198,6 +198,7 @@ var rollupFuncsKeepMetricGroup = map[string]bool{ "first_over_time": true, "last_over_time": true, "mode_over_time": true, + "rollup_candlestick": true, } func getRollupAggrFuncNames(expr metricsql.Expr) ([]string, error) { diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index 12e476c3d..07d0e5ea1 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -13,6 +13,7 @@ sort: 15 * FAETURE: allow splitting long `regex` in relabeling filters into an array of shorter regexps, which can be put into multiple lines for better readability and maintainability. See [these docs](https://docs.victoriametrics.com/vmagent.html#relabeling) for more details. * BUGFIX: vmselect: reset connection timeouts after each request to `vmstorage`. This should prevent from `cannot read data in 0.000 seconds: unexpected EOF` warning in logs. See [this issue](https://github.com/VictoriaMetrics/VictoriaMetrics/issues/1562). Thanks to @mxlxm . +* BUGFIX: keep metric name for time series returned from [rollup_candlestick](https://docs.victoriametrics.com/MetricsQL.html#rollup_candlestick) function, since the returned series don't change the meaning of the original series. See [this issue](https://github.com/VictoriaMetrics/VictoriaMetrics/issues/1600). ## [v1.65.0](https://github.com/VictoriaMetrics/VictoriaMetrics/releases/tag/v1.65.0)