@@ -22,6 +22,7 @@ func rejectQueryOrSetPriority(r *http.Request, now time.Time, lookbackDelta time
2222 return nil
2323 }
2424 op := getOperation (r )
25+ reqStats := stats .FromContext (r .Context ())
2526
2627 if op == "query" || op == "query_range" {
2728 query := r .FormValue ("query" )
@@ -40,7 +41,6 @@ func rejectQueryOrSetPriority(r *http.Request, now time.Time, lookbackDelta time
4041 }
4142 }
4243
43- reqStats := stats .FromContext (r .Context ())
4444 reqStats .SetDataSelectMaxTime (maxTime )
4545 reqStats .SetDataSelectMinTime (minTime )
4646
@@ -55,6 +55,16 @@ func rejectQueryOrSetPriority(r *http.Request, now time.Time, lookbackDelta time
5555 }
5656 reqStats .SetPriority (queryPriority .DefaultPriority )
5757 }
58+ } else {
59+ if queryPriority := limits .QueryPriority (userStr ); queryPriority .Enabled && len (queryPriority .Priorities ) != 0 {
60+ for _ , priority := range queryPriority .Priorities {
61+ for _ , attribute := range priority .QueryAttributes {
62+ if matchAttributeForMetadataQuery (attribute , op , r , now ) {
63+ reqStats .SetPriority (priority .Priority )
64+ }
65+ }
66+ }
67+ }
5868 }
5969
6070 if queryReject := limits .QueryRejection (userStr ); queryReject .Enabled && (op == "series" || op == "labels" || op == "label_values" ) {
@@ -81,6 +91,8 @@ func getOperation(r *http.Request) string {
8191 return "labels"
8292 case strings .HasSuffix (r .URL .Path , "/values" ):
8393 return "label_values"
94+ case strings .HasSuffix (r .URL .Path , "/metadata" ):
95+ return "metadata"
8496 default :
8597 return "other"
8698 }
0 commit comments