mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-12-15 08:23:34 +01:00
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/
This commit is contained in:
parent
01000505a0
commit
7f93d61a56
@ -645,7 +645,6 @@ func TestExecSuccess(t *testing.T) {
|
|||||||
Values: []float64{1000, 1200, 1400, 1400, 1400, 1400},
|
Values: []float64{1000, 1200, 1400, 1400, 1400, 1400},
|
||||||
Timestamps: timestampsExpected,
|
Timestamps: timestampsExpected,
|
||||||
}
|
}
|
||||||
r.MetricName.MetricGroup = []byte("foobar")
|
|
||||||
resultExpected := []netstorage.Result{r}
|
resultExpected := []netstorage.Result{r}
|
||||||
f(q, resultExpected)
|
f(q, resultExpected)
|
||||||
})
|
})
|
||||||
@ -657,7 +656,6 @@ func TestExecSuccess(t *testing.T) {
|
|||||||
Values: []float64{1000, 1200, 1400, 1400, 1400, 1400},
|
Values: []float64{1000, 1200, 1400, 1400, 1400, 1400},
|
||||||
Timestamps: timestampsExpected,
|
Timestamps: timestampsExpected,
|
||||||
}
|
}
|
||||||
r.MetricName.MetricGroup = []byte("foobar")
|
|
||||||
resultExpected := []netstorage.Result{r}
|
resultExpected := []netstorage.Result{r}
|
||||||
f(q, resultExpected)
|
f(q, resultExpected)
|
||||||
})
|
})
|
||||||
|
@ -17,11 +17,6 @@ import (
|
|||||||
"github.com/valyala/histogram"
|
"github.com/valyala/histogram"
|
||||||
)
|
)
|
||||||
|
|
||||||
var transformFuncsKeepMetricGroup = map[string]bool{
|
|
||||||
"clamp_max": true,
|
|
||||||
"clamp_min": true,
|
|
||||||
}
|
|
||||||
|
|
||||||
var transformFuncs = map[string]transformFunc{
|
var transformFuncs = map[string]transformFunc{
|
||||||
// Standard promql funcs
|
// Standard promql funcs
|
||||||
// See funcs accepting instant-vector on https://prometheus.io/docs/prometheus/latest/querying/functions/ .
|
// 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) {
|
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 {
|
for _, ts := range arg {
|
||||||
if !keepMetricGroup {
|
ts.MetricName.ResetMetricGroup()
|
||||||
ts.MetricName.ResetMetricGroup()
|
|
||||||
}
|
|
||||||
tf(ts.Values)
|
tf(ts.Values)
|
||||||
}
|
}
|
||||||
return arg, nil
|
return arg, nil
|
||||||
|
Loading…
Reference in New Issue
Block a user