app/vmselect/prometheus: prevent from fetching and scanning all the data on /api/v1/searies call by default

This commit is contained in:
Aliaksandr Valialkin 2019-08-04 19:42:36 +03:00
parent 000c154641
commit 7f5afae1e3

View File

@ -376,13 +376,16 @@ func SeriesHandler(at *auth.Token, w http.ResponseWriter, r *http.Request) error
if len(matches) == 0 {
return fmt.Errorf("missing `match[]` arg")
}
// Set start to minTimeMsecs by default as Prometheus does.
// See https://github.com/VictoriaMetrics/VictoriaMetrics/issues/91
start, err := getTime(r, "start", minTimeMsecs)
end, err := getTime(r, "end", ct)
if err != nil {
return err
}
end, err := getTime(r, "end", ct)
// Do not set start to minTimeMsecs by default as Prometheus does,
// since this leads to fetching and scanning all the data from the storage,
// which can take a lot of time for big storages.
// It is better setting start as end-defaultStep by default.
// See https://github.com/VictoriaMetrics/VictoriaMetrics/issues/91
start, err := getTime(r, "start", end-defaultStep)
if err != nil {
return err
}