@@ -431,7 +431,7 @@ func (q querier) Select(ctx context.Context, sortSeries bool, sp *storage.Select
431
431
432
432
// LabelValues implements storage.Querier.
433
433
func (q querier ) LabelValues (ctx context.Context , name string , hints * storage.LabelHints , matchers ... * labels.Matcher ) ([]string , annotations.Annotations , error ) {
434
- ctx , stats , _ , _ , _ , _ , queriers , err := q .setupFromCtx (ctx )
434
+ ctx , stats , userID , mint , maxt , _ , queriers , err := q .setupFromCtx (ctx )
435
435
if err == errEmptyTimeRange {
436
436
return nil , nil , nil
437
437
} else if err != nil {
@@ -442,6 +442,14 @@ func (q querier) LabelValues(ctx context.Context, name string, hints *storage.La
442
442
stats .AddQueryStorageWallTime (time .Since (startT ))
443
443
}()
444
444
445
+ startTime := model .Time (mint )
446
+ endTime := model .Time (maxt )
447
+
448
+ if maxQueryLength := q .limits .MaxQueryLength (userID ); maxQueryLength > 0 && endTime .Sub (startTime ) > maxQueryLength {
449
+ limitErr := validation .LimitError (fmt .Sprintf (validation .ErrQueryTooLong , endTime .Sub (startTime ), maxQueryLength ))
450
+ return nil , nil , limitErr
451
+ }
452
+
445
453
if len (queriers ) == 1 {
446
454
return queriers [0 ].LabelValues (ctx , name , hints , matchers ... )
447
455
}
@@ -481,7 +489,7 @@ func (q querier) LabelValues(ctx context.Context, name string, hints *storage.La
481
489
}
482
490
483
491
func (q querier ) LabelNames (ctx context.Context , hints * storage.LabelHints , matchers ... * labels.Matcher ) ([]string , annotations.Annotations , error ) {
484
- ctx , stats , _ , _ , _ , _ , queriers , err := q .setupFromCtx (ctx )
492
+ ctx , stats , userID , mint , maxt , _ , queriers , err := q .setupFromCtx (ctx )
485
493
if err == errEmptyTimeRange {
486
494
return nil , nil , nil
487
495
} else if err != nil {
@@ -492,6 +500,14 @@ func (q querier) LabelNames(ctx context.Context, hints *storage.LabelHints, matc
492
500
stats .AddQueryStorageWallTime (time .Since (startT ))
493
501
}()
494
502
503
+ startTime := model .Time (mint )
504
+ endTime := model .Time (maxt )
505
+
506
+ if maxQueryLength := q .limits .MaxQueryLength (userID ); maxQueryLength > 0 && endTime .Sub (startTime ) > maxQueryLength {
507
+ limitErr := validation .LimitError (fmt .Sprintf (validation .ErrQueryTooLong , endTime .Sub (startTime ), maxQueryLength ))
508
+ return nil , nil , limitErr
509
+ }
510
+
495
511
if len (queriers ) == 1 {
496
512
return queriers [0 ].LabelNames (ctx , hints , matchers ... )
497
513
}
0 commit comments