From 7f93d61a56d80358d0b96c50accd77d313aad425 Mon Sep 17 00:00:00 2001 From: Aliaksandr Valialkin Date: Thu, 6 Aug 2020 23:42:14 +0300 Subject: [PATCH] app/vmselect/promql: remove metric name after applying `clamp_min` and `clamp_max` functions in order to be consistent with Prometheus This improves VictoriaMetrics score at https://promlabs.com/promql-compliance-test-results-victoriametrics/ --- app/vmselect/promql/exec_test.go | 2 -- app/vmselect/promql/transform.go | 11 +---------- 2 files changed, 1 insertion(+), 12 deletions(-) diff --git a/app/vmselect/promql/exec_test.go b/app/vmselect/promql/exec_test.go index 36570bf34f..c61861ceca 100644 --- a/app/vmselect/promql/exec_test.go +++ b/app/vmselect/promql/exec_test.go @@ -645,7 +645,6 @@ func TestExecSuccess(t *testing.T) { Values: []float64{1000, 1200, 1400, 1400, 1400, 1400}, Timestamps: timestampsExpected, } - r.MetricName.MetricGroup = []byte("foobar") resultExpected := []netstorage.Result{r} f(q, resultExpected) }) @@ -657,7 +656,6 @@ func TestExecSuccess(t *testing.T) { Values: []float64{1000, 1200, 1400, 1400, 1400, 1400}, Timestamps: timestampsExpected, } - r.MetricName.MetricGroup = []byte("foobar") resultExpected := []netstorage.Result{r} f(q, resultExpected) }) diff --git a/app/vmselect/promql/transform.go b/app/vmselect/promql/transform.go index a8875927b1..16ca9cc7f1 100644 --- a/app/vmselect/promql/transform.go +++ b/app/vmselect/promql/transform.go @@ -17,11 +17,6 @@ import ( "github.com/valyala/histogram" ) -var transformFuncsKeepMetricGroup = map[string]bool{ - "clamp_max": true, - "clamp_min": true, -} - var transformFuncs = map[string]transformFunc{ // Standard promql funcs // See funcs accepting instant-vector on https://prometheus.io/docs/prometheus/latest/querying/functions/ . @@ -130,12 +125,8 @@ func newTransformFuncOneArg(tf func(v float64) float64) transformFunc { } func doTransformValues(arg []*timeseries, tf func(values []float64), fe *metricsql.FuncExpr) ([]*timeseries, error) { - name := strings.ToLower(fe.Name) - keepMetricGroup := transformFuncsKeepMetricGroup[name] for _, ts := range arg { - if !keepMetricGroup { - ts.MetricName.ResetMetricGroup() - } + ts.MetricName.ResetMetricGroup() tf(ts.Values) } return arg, nil