Add hint that the series endpoint is being used to the tsdb.

Currently the series endpoint is paging in all chunks for
matched series, which can be rather slow.

Signed-off-by: Brian Brazil <brian.brazil@robustperception.io>
This commit is contained in:
Brian Brazil 2020-04-04 13:07:12 +01:00
parent 62bd77bf93
commit b7c44147f0
2 changed files with 14 additions and 1 deletions

View file

@ -207,6 +207,13 @@ func (q *blockQuerier) Select(sortSeries bool, hints *storage.SelectHints, ms ..
if hints != nil {
mint = hints.Start
maxt = hints.End
if hints.Func == "series" { // The series API does not need any chunks loaded.
return &blockSeriesSet{
set: base,
mint: mint,
maxt: maxt,
}, nil, nil
}
}
return &blockSeriesSet{
set: &populatedChunkSeries{

View file

@ -528,10 +528,16 @@ func (api *API) series(r *http.Request) apiFuncResult {
}
defer q.Close()
hints := &storage.SelectHints{
Start: timestamp.FromTime(start),
End: timestamp.FromTime(end),
Func: "series", // There is no series function.
}
var sets []storage.SeriesSet
var warnings storage.Warnings
for _, mset := range matcherSets {
s, wrn, err := q.Select(false, nil, mset...)
s, wrn, err := q.Select(false, hints, mset...)
warnings = append(warnings, wrn...)
if err != nil {
return apiFuncResult{nil, &apiError{errorExec, err}, warnings, nil}