@@ -63,6 +63,7 @@ import (
63
63
"github.com/cortexproject/cortex/pkg/util/limiter"
64
64
logutil "github.com/cortexproject/cortex/pkg/util/log"
65
65
util_math "github.com/cortexproject/cortex/pkg/util/math"
66
+ "github.com/cortexproject/cortex/pkg/util/requestmeta"
66
67
"github.com/cortexproject/cortex/pkg/util/resource"
67
68
"github.com/cortexproject/cortex/pkg/util/services"
68
69
"github.com/cortexproject/cortex/pkg/util/spanlogger"
@@ -1696,7 +1697,7 @@ func (i *Ingester) QueryExemplars(ctx context.Context, req *client.ExemplarQuery
1696
1697
}
1697
1698
1698
1699
// We will report *this* request in the error too.
1699
- c , err := i .trackInflightQueryRequest ()
1700
+ c , err := i .trackInflightQueryRequest (ctx )
1700
1701
if err != nil {
1701
1702
return nil , err
1702
1703
}
@@ -1804,7 +1805,7 @@ func (i *Ingester) labelsValuesCommon(ctx context.Context, req *client.LabelValu
1804
1805
q .Close ()
1805
1806
}
1806
1807
1807
- c , err := i .trackInflightQueryRequest ()
1808
+ c , err := i .trackInflightQueryRequest (ctx )
1808
1809
if err != nil {
1809
1810
return nil , cleanup , err
1810
1811
}
@@ -1901,7 +1902,7 @@ func (i *Ingester) labelNamesCommon(ctx context.Context, req *client.LabelNamesR
1901
1902
q .Close ()
1902
1903
}
1903
1904
1904
- c , err := i .trackInflightQueryRequest ()
1905
+ c , err := i .trackInflightQueryRequest (ctx )
1905
1906
if err != nil {
1906
1907
return nil , cleanup , err
1907
1908
}
@@ -2252,7 +2253,7 @@ func (i *Ingester) QueryStream(req *client.QueryRequest, stream client.Ingester_
2252
2253
return nil
2253
2254
}
2254
2255
2255
- func (i * Ingester ) trackInflightQueryRequest () (func (), error ) {
2256
+ func (i * Ingester ) trackInflightQueryRequest (ctx context. Context ) (func (), error ) {
2256
2257
gl := i .getInstanceLimits ()
2257
2258
if gl != nil && gl .MaxInflightQueryRequests > 0 {
2258
2259
if i .inflightQueryRequests .Load () >= gl .MaxInflightQueryRequests {
@@ -2262,7 +2263,7 @@ func (i *Ingester) trackInflightQueryRequest() (func(), error) {
2262
2263
2263
2264
i .maxInflightQueryRequests .Track (i .inflightQueryRequests .Inc ())
2264
2265
2265
- if i .resourceBasedLimiter != nil {
2266
+ if i .resourceBasedLimiter != nil && requestmeta . RequestSourceFromContext ( ctx ) == requestmeta . SourceApi {
2266
2267
if err := i .resourceBasedLimiter .AcceptNewRequest (); err != nil {
2267
2268
level .Warn (i .logger ).Log ("msg" , "failed to accept request" , "err" , err )
2268
2269
return nil , httpgrpc .Errorf (http .StatusServiceUnavailable , "failed to query: %s" , limiter .ErrResourceLimitReachedStr )
@@ -2282,7 +2283,7 @@ func (i *Ingester) queryStreamChunks(ctx context.Context, db *userTSDB, from, th
2282
2283
}
2283
2284
defer q .Close ()
2284
2285
2285
- c , err := i .trackInflightQueryRequest ()
2286
+ c , err := i .trackInflightQueryRequest (ctx )
2286
2287
if err != nil {
2287
2288
return 0 , 0 , 0 , 0 , err
2288
2289
}
0 commit comments