Documentation
¶
Index ¶
- Constants
- func ClientQueryLimitsInterceptor(ctx context.Context, method string, req, reply interface{}, ...) error
- func InjectQueryLimitsContextHTTP(r *http.Request, limitsCtx *Context) error
- func InjectQueryLimitsContextHeader(h *http.Header, limitsCtx *Context) error
- func InjectQueryLimitsContextIntoContext(ctx context.Context, limitsCtx Context) context.Context
- func InjectQueryLimitsHTTP(r *http.Request, limits *QueryLimits) error
- func InjectQueryLimitsHeader(h *http.Header, limits *QueryLimits) error
- func InjectQueryLimitsIntoContext(ctx context.Context, limits QueryLimits) context.Context
- func MarshalQueryLimits(limits *QueryLimits) ([]byte, error)
- func MarshalQueryLimitsContext(limits *Context) ([]byte, error)
- func NewQueryLimitsMiddleware(logger log.Logger) middleware.Interface
- func ServerQueryLimitsInterceptor(ctx context.Context, req interface{}, _ *grpc.UnaryServerInfo, ...) (interface{}, error)
- func StreamClientQueryLimitsInterceptor(ctx context.Context, desc *grpc.StreamDesc, cc *grpc.ClientConn, method string, ...) (grpc.ClientStream, error)
- func StreamServerQueryLimitsInterceptor(srv interface{}, ss grpc.ServerStream, _ *grpc.StreamServerInfo, ...) error
- type Context
- type Limiter
- func (l *Limiter) MaxEntriesLimitPerQuery(ctx context.Context, userID string) int
- func (l *Limiter) MaxQueryBytesRead(ctx context.Context, userID string) int
- func (l *Limiter) MaxQueryLength(ctx context.Context, userID string) time.Duration
- func (l *Limiter) MaxQueryLookback(ctx context.Context, userID string) time.Duration
- func (l *Limiter) MaxQueryRange(ctx context.Context, userID string) time.Duration
- func (l *Limiter) QueryTimeout(ctx context.Context, userID string) time.Duration
- func (l *Limiter) RequiredLabels(ctx context.Context, userID string) []string
- func (l *Limiter) RequiredNumberLabels(ctx context.Context, userID string) int
- type QueryLimits
Constants ¶
const ( HTTPHeaderQueryLimitsKey = "X-Loki-Query-Limits" HTTPHeaderQueryLimitsContextKey = "X-Loki-Query-Limits-Context" )
Variables ¶
This section is empty.
Functions ¶
func ClientQueryLimitsInterceptor ¶
func ClientQueryLimitsInterceptor(ctx context.Context, method string, req, reply interface{}, cc *grpc.ClientConn, invoker grpc.UnaryInvoker, opts ...grpc.CallOption) error
func InjectQueryLimitsContextHTTP ¶ added in v3.7.0
InjectQueryLimitsContextHTTP adds the query limits context to the request headers.
func InjectQueryLimitsContextHeader ¶ added in v3.7.0
InjectQueryLimitsContextHeader adds the query limits context to the headers.
func InjectQueryLimitsContextIntoContext ¶ added in v3.7.0
InjectQueryLimitsContextIntoContext returns a derived context containing the provided query limits context
func InjectQueryLimitsHTTP ¶
func InjectQueryLimitsHTTP(r *http.Request, limits *QueryLimits) error
InjectQueryLimitsHTTP adds the query limits to the request headers.
func InjectQueryLimitsHeader ¶
func InjectQueryLimitsHeader(h *http.Header, limits *QueryLimits) error
InjectQueryLimitsHeader adds the query limits to the headers.
func InjectQueryLimitsIntoContext ¶ added in v3.7.0
func InjectQueryLimitsIntoContext(ctx context.Context, limits QueryLimits) context.Context
InjectQueryLimitsIntoContext returns a derived context containing the provided query limits
func MarshalQueryLimits ¶
func MarshalQueryLimits(limits *QueryLimits) ([]byte, error)
func MarshalQueryLimitsContext ¶ added in v3.7.0
func NewQueryLimitsMiddleware ¶
func NewQueryLimitsMiddleware(logger log.Logger) middleware.Interface
NewQueryLimitsMiddleware creates a middleware that extracts the query limits policy from the HTTP header and injects it into the context of the request.
func ServerQueryLimitsInterceptor ¶
func ServerQueryLimitsInterceptor(ctx context.Context, req interface{}, _ *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (interface{}, error)
func StreamClientQueryLimitsInterceptor ¶
func StreamClientQueryLimitsInterceptor(ctx context.Context, desc *grpc.StreamDesc, cc *grpc.ClientConn, method string, streamer grpc.Streamer, opts ...grpc.CallOption) (grpc.ClientStream, error)
func StreamServerQueryLimitsInterceptor ¶
func StreamServerQueryLimitsInterceptor(srv interface{}, ss grpc.ServerStream, _ *grpc.StreamServerInfo, handler grpc.StreamHandler) error
Types ¶
type Context ¶ added in v3.7.0
type Context struct {
Expr string `json:"expr"`
From time.Time `json:"from"`
To time.Time `json:"to"`
}
func ExtractQueryLimitsContextFromContext ¶ added in v3.7.0
ExtractQueryLimitsContextFromContext gets the embedded query limits context from the context
func ExtractQueryLimitsContextHTTP ¶ added in v3.7.0
ExtractQueryLimitsContextHTTP retrieves the query limits context from the HTTP header and returns it.
func UnmarshalQueryLimitsContext ¶ added in v3.7.0
type Limiter ¶
type Limiter struct {
limiter.CombinedLimits
// contains filtered or unexported fields
}
func NewLimiter ¶
func NewLimiter(log log.Logger, original limiter.CombinedLimits) *Limiter
func (*Limiter) MaxEntriesLimitPerQuery ¶
MaxEntriesLimitPerQuery returns the limit to number of entries the querier should return per query.
func (*Limiter) MaxQueryBytesRead ¶
func (*Limiter) MaxQueryLength ¶
MaxQueryLength returns the limit of the length (in time) of a query.
func (*Limiter) MaxQueryLookback ¶
MaxQueryLookback returns the max lookback period of queries.
func (*Limiter) MaxQueryRange ¶
MaxQueryRange retruns the max query range/interval of a query.
func (*Limiter) QueryTimeout ¶
func (*Limiter) RequiredLabels ¶
type QueryLimits ¶
type QueryLimits struct {
MaxQueryLength model.Duration `json:"maxQueryLength,omitempty"`
MaxQueryRange model.Duration `json:"maxQueryInterval,omitempty"`
MaxQueryLookback model.Duration `json:"maxQueryLookback,omitempty"`
MaxEntriesLimitPerQuery int `json:"maxEntriesLimitPerQuery,omitempty"`
QueryTimeout model.Duration `json:"maxQueryTime,omitempty"`
RequiredLabels []string `json:"requiredLabels,omitempty"`
RequiredNumberLabels int `json:"minimumLabelsNumber,omitempty"`
MaxQueryBytesRead flagext.ByteSize `json:"maxQueryBytesRead,omitempty"`
}
NOTE: we use custom `model.Duration` instead of standard `time.Duration` because, to support user-friendly duration format (e.g: "1h30m45s") in JSON value.
func ExtractQueryLimitsFromContext ¶ added in v3.7.0
func ExtractQueryLimitsFromContext(ctx context.Context) *QueryLimits
ExtractQueryLimitsFromContext gets the embedded limits from the context
func ExtractQueryLimitsHTTP ¶
func ExtractQueryLimitsHTTP(r *http.Request) (*QueryLimits, error)
ExtractQueryLimitsHTTP retrieves the query limit policy from the HTTP header and returns it.
func UnmarshalQueryLimits ¶
func UnmarshalQueryLimits(data []byte) (*QueryLimits, error)