Documentation ¶
Index ¶
- Constants
- func ClientQueryLimitsInterceptor(ctx context.Context, method string, req, reply interface{}, ...) error
- func InjectQueryLimitsContext(ctx context.Context, limits QueryLimits) context.Context
- func InjectQueryLimitsHTTP(r *http.Request, limits *QueryLimits) error
- func InjectQueryLimitsHeader(h *http.Header, limits *QueryLimits) error
- func MarshalQueryLimits(limits *QueryLimits) ([]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 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"
)
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 InjectQueryLimitsContext ¶
func InjectQueryLimitsContext(ctx context.Context, limits QueryLimits) context.Context
InjectQueryLimitsContext returns a derived context containing the provided query limits
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 MarshalQueryLimits ¶
func MarshalQueryLimits(limits *QueryLimits) ([]byte, error)
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 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 ExtractQueryLimitsContext ¶
func ExtractQueryLimitsContext(ctx context.Context) *QueryLimits
ExtractQueryLimitsContext 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)