add endTime variable for promeClient.Series api

Signed-off-by: 屈骏 <qujun@tiduyun.com>
This commit is contained in:
屈骏 2020-07-22 10:51:08 +08:00
parent 6e05ab938e
commit 5e169f5b0d
3 changed files with 6 additions and 3 deletions

View file

@ -218,6 +218,7 @@ type selectorSeries struct {
func (l *cachingMetricsLister) updateMetrics() error {
startTime := pmodel.Now().Add(-1 * l.maxAge)
endTime := pmodel.Now().Add(1 * l.maxAge)
// don't do duplicate queries when it's just the matchers that change
seriesCacheByQuery := make(map[prom.Selector][]prom.Series)
@ -236,7 +237,7 @@ func (l *cachingMetricsLister) updateMetrics() error {
}
selectors[sel] = struct{}{}
go func() {
series, err := l.promClient.Series(context.TODO(), pmodel.Interval{startTime, 0}, sel)
series, err := l.promClient.Series(context.TODO(), pmodel.Interval{startTime, endTime}, sel)
if err != nil {
errs <- fmt.Errorf("unable to fetch metrics for query %q: %v", sel, err)
return