mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2025-02-19 15:30:17 +00:00
app/vmselect/promql: return a single time series at max from absent()
function like Prometheus does
This commit is contained in:
parent
217c192c88
commit
b9a4601c97
3 changed files with 14 additions and 16 deletions
|
@ -53,6 +53,7 @@
|
||||||
|
|
||||||
* BUGFIX: properly handle stale time series after K8S deployment. Previously such time series could be double-counted.
|
* BUGFIX: properly handle stale time series after K8S deployment. Previously such time series could be double-counted.
|
||||||
See https://github.com/VictoriaMetrics/VictoriaMetrics/issues/748
|
See https://github.com/VictoriaMetrics/VictoriaMetrics/issues/748
|
||||||
|
* BUGFIX: return a single time series at max from `absent()` function like Prometheus does.
|
||||||
* BUGFIX: vmalert: accept days, weeks and years in `for: ` part of config like Prometheus does. See https://github.com/VictoriaMetrics/VictoriaMetrics/issues/817
|
* BUGFIX: vmalert: accept days, weeks and years in `for: ` part of config like Prometheus does. See https://github.com/VictoriaMetrics/VictoriaMetrics/issues/817
|
||||||
* BUGFIX: fix `mode_over_time(m[d])` calculations. Previously the function could return incorrect results.
|
* BUGFIX: fix `mode_over_time(m[d])` calculations. Previously the function could return incorrect results.
|
||||||
|
|
||||||
|
|
|
@ -592,10 +592,6 @@ func TestExecSuccess(t *testing.T) {
|
||||||
Values: []float64{1, 1, 1, 1, 1, 1},
|
Values: []float64{1, 1, 1, 1, 1, 1},
|
||||||
Timestamps: timestampsExpected,
|
Timestamps: timestampsExpected,
|
||||||
}
|
}
|
||||||
r.MetricName.Tags = []storage.Tag{{
|
|
||||||
Key: []byte("yy"),
|
|
||||||
Value: []byte("foo"),
|
|
||||||
}}
|
|
||||||
resultExpected := []netstorage.Result{r}
|
resultExpected := []netstorage.Result{r}
|
||||||
f(q, resultExpected)
|
f(q, resultExpected)
|
||||||
})
|
})
|
||||||
|
|
|
@ -167,23 +167,24 @@ func transformAbsent(tfa *transformFuncArg) ([]*timeseries, error) {
|
||||||
if err := expectTransformArgsNum(args, 1); err != nil {
|
if err := expectTransformArgsNum(args, 1); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
arg := args[0]
|
tss := args[0]
|
||||||
if len(arg) == 0 {
|
rvs := getAbsentTimeseries(tfa.ec, tfa.fe.Args[0])
|
||||||
rvs := getAbsentTimeseries(tfa.ec, tfa.fe.Args[0])
|
if len(tss) == 0 {
|
||||||
return rvs, nil
|
return rvs, nil
|
||||||
}
|
}
|
||||||
for _, ts := range arg {
|
for i := range tss[0].Values {
|
||||||
ts.MetricName.ResetMetricGroup()
|
isAbsent := true
|
||||||
for i, v := range ts.Values {
|
for _, ts := range tss {
|
||||||
if !math.IsNaN(v) {
|
if !math.IsNaN(ts.Values[i]) {
|
||||||
v = nan
|
isAbsent = false
|
||||||
} else {
|
break
|
||||||
v = 1
|
|
||||||
}
|
}
|
||||||
ts.Values[i] = v
|
}
|
||||||
|
if !isAbsent {
|
||||||
|
rvs[0].Values[i] = nan
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return arg, nil
|
return rvs, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func getAbsentTimeseries(ec *EvalConfig, arg metricsql.Expr) []*timeseries {
|
func getAbsentTimeseries(ec *EvalConfig, arg metricsql.Expr) []*timeseries {
|
||||||
|
|
Loading…
Reference in a new issue