Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( ErrMaxSeriesHit = "the query hit the max number of series limit (limit: %d series)" ErrMaxChunkBytesHit = "the query hit the aggregated chunks size limit (limit: %d bytes)" ErrMaxDataBytesHit = "the query hit the aggregated data size limit (limit: %d bytes)" ErrMaxChunksPerQueryLimit = "the query hit the max number of chunks limit (limit: %d chunks)" )
Functions ¶
func AddQueryLimiterToContext ¶ added in v1.10.0
func AddQueryLimiterToContext(ctx context.Context, limiter *QueryLimiter) context.Context
Types ¶
type QueryLimiter ¶ added in v1.10.0
type QueryLimiter struct {
// contains filtered or unexported fields
}
func NewQueryLimiter ¶ added in v1.10.0
func NewQueryLimiter(maxSeriesPerQuery, maxChunkBytesPerQuery, maxChunksPerQuery, maxDataBytesPerQuery int) *QueryLimiter
NewQueryLimiter makes a new per-query limiter. Each query limiter is configured using the `maxSeriesPerQuery` limit.
func QueryLimiterFromContextWithFallback ¶ added in v1.10.0
func QueryLimiterFromContextWithFallback(ctx context.Context) *QueryLimiter
QueryLimiterFromContextWithFallback returns a QueryLimiter from the current context. If there is not a QueryLimiter on the context it will return a new no-op limiter.
func (*QueryLimiter) AddChunkBytes ¶ added in v1.10.0
func (ql *QueryLimiter) AddChunkBytes(chunkSizeInBytes int) error
AddChunkBytes adds the input chunk size in bytes and returns an error if the limit is reached.
func (*QueryLimiter) AddChunks ¶ added in v1.11.0
func (ql *QueryLimiter) AddChunks(count int) error
func (*QueryLimiter) AddDataBytes ¶ added in v1.14.0
func (ql *QueryLimiter) AddDataBytes(dataSizeInBytes int) error
AddDataBytes adds the queried data bytes and returns an error if the limit is reached.
func (*QueryLimiter) AddSeries ¶ added in v1.10.0
func (ql *QueryLimiter) AddSeries(series ...[]cortexpb.LabelAdapter) error
AddSeries adds the batch of input series and returns an error if the limit is reached.
type RateLimiter ¶
type RateLimiter struct {
// contains filtered or unexported fields
}
RateLimiter is a multi-tenant local rate limiter based on golang.org/x/time/rate. It requires a custom strategy in input, which is used to get the limit and burst settings for each tenant.
func NewRateLimiter ¶
func NewRateLimiter(strategy RateLimiterStrategy, recheckPeriod time.Duration) *RateLimiter
NewRateLimiter makes a new multi-tenant rate limiter. Each per-tenant limiter is configured using the input strategy and its limit/burst is rechecked (and reconfigured if changed) every recheckPeriod.
type RateLimiterStrategy ¶
RateLimiterStrategy defines the interface which a pluggable strategy should implement. The returned limit and burst can change over the time, and the local rate limiter will apply them every recheckPeriod.