old-alert: set interval and max-data-points (#38434)

* alerting: old-alerting: handle interval + maxdatapoints better

* fixed failing test

* refactor: use interval instead of tsdb

* fix typo

* added unit-test

* added comment

* refactor
This commit is contained in:
Gábor Farkas
2021-08-31 14:49:30 +02:00
committed by GitHub
parent fec50115b0
commit aa7a6633b8
3 changed files with 205 additions and 9 deletions
+2 -2
View File
@@ -13,7 +13,7 @@ import (
)
var (
defaultRes int64 = 1500
DefaultRes int64 = 1500
defaultMinInterval = time.Millisecond * 1
year = time.Hour * 24 * 365
day = time.Hour * 24
@@ -58,7 +58,7 @@ func (i *Interval) Milliseconds() int64 {
func (ic *intervalCalculator) Calculate(timerange plugins.DataTimeRange, interval time.Duration, intervalMode string) (Interval, error) {
to := timerange.MustGetTo().UnixNano()
from := timerange.MustGetFrom().UnixNano()
calculatedInterval := time.Duration((to - from) / defaultRes)
calculatedInterval := time.Duration((to - from) / DefaultRes)
switch intervalMode {
case "min":