mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-12-15 00:13:30 +01:00
app/vmselect/promql: consistently return zero from deriv(const)
This commit is contained in:
parent
e93f46187d
commit
84decc4254
@ -6419,9 +6419,9 @@ func TestExecSuccess(t *testing.T) {
|
||||
resultExpected := []netstorage.Result{r}
|
||||
f(q, resultExpected)
|
||||
})
|
||||
t.Run(`deriv(1)`, func(t *testing.T) {
|
||||
t.Run(`deriv(N)`, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
q := `deriv(1)`
|
||||
q := `deriv(1000)`
|
||||
r := netstorage.Result{
|
||||
MetricName: metricNameExpected,
|
||||
Values: []float64{0, 0, 0, 0, 0, 0},
|
||||
|
@ -850,7 +850,7 @@ func linearRegression(rfa *rollupFuncArg) (float64, float64) {
|
||||
if n == 0 {
|
||||
return nan, nan
|
||||
}
|
||||
if n == 1 {
|
||||
if areConstValues(values) {
|
||||
return values[0], 0
|
||||
}
|
||||
|
||||
@ -877,6 +877,20 @@ func linearRegression(rfa *rollupFuncArg) (float64, float64) {
|
||||
return v, k
|
||||
}
|
||||
|
||||
func areConstValues(values []float64) bool {
|
||||
if len(values) <= 1 {
|
||||
return true
|
||||
}
|
||||
vPrev := values[0]
|
||||
for _, v := range values[1:] {
|
||||
if v != vPrev {
|
||||
return false
|
||||
}
|
||||
vPrev = v
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
func newRollupDurationOverTime(args []interface{}) (rollupFunc, error) {
|
||||
if err := expectRollupArgsNum(args, 2); err != nil {
|
||||
return nil, err
|
||||
|
@ -15,6 +15,7 @@ sort: 15
|
||||
* BUGFIX: vmauth: properly take into account the value passed to `-maxIdleConnsPerBackend` command-line flag. See [this issue](https://github.com/VictoriaMetrics/VictoriaMetrics/issues/1300).
|
||||
* BUGFIX: vmagent: fix [reading data from Kafka](https://docs.victoriametrics.com/vmagent.html#reading-metrics-from-kafka).
|
||||
* BUGFIX: vmalert: fix [replay mode](https://docs.victoriametrics.com/vmalert.html#rules-backfilling) in enterprise version.
|
||||
* BUGFIX: consistently return zero from [deriv()](https://docs.victoriametrics.com/MetricsQL.html#deriv) function applied to a constant time series. Previously it could return small non-zero values in this case.
|
||||
|
||||
|
||||
## [v1.69.0](https://github.com/VictoriaMetrics/VictoriaMetrics/releases/tag/v1.69.0)
|
||||
|
@ -47,6 +47,7 @@ Each `url_prefix` in the [-auth.config](#auth-config) may contain either a singl
|
||||
users:
|
||||
# Requests with the 'Authorization: Bearer XXXX' header are proxied to http://localhost:8428 .
|
||||
# For example, http://vmauth:8427/api/v1/query is proxied to http://localhost:8428/api/v1/query
|
||||
# Requests with the Basic Auth username=XXXX are proxied to http://localhost:8428 as well.
|
||||
- bearer_token: "XXXX"
|
||||
url_prefix: "http://localhost:8428"
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user