Documentation
¶
Index ¶
- type ErrQueryEvicted
- type MetricFunc
- type QueryEntry
- type QueryEvictor
- type QueryRegistry
- type ResourceEvictingEngine
- func (e *ResourceEvictingEngine) MakeInstantQueryFromPlan(ctx context.Context, q storage.Queryable, opts promql.QueryOpts, ...) (promql.Query, error)
- func (e *ResourceEvictingEngine) MakeRangeQueryFromPlan(ctx context.Context, q storage.Queryable, opts promql.QueryOpts, ...) (promql.Query, error)
- func (e *ResourceEvictingEngine) NewInstantQuery(ctx context.Context, q storage.Queryable, opts promql.QueryOpts, qs string, ...) (promql.Query, error)
- func (e *ResourceEvictingEngine) NewRangeQuery(ctx context.Context, q storage.Queryable, opts promql.QueryOpts, qs string, ...) (promql.Query, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ErrQueryEvicted ¶
type ErrQueryEvicted struct{}
ErrQueryEvicted is returned when a query is cancelled by the evictor.
func (*ErrQueryEvicted) Error ¶
func (e *ErrQueryEvicted) Error() string
type MetricFunc ¶
type MetricFunc func(s *querier_stats.QueryStats) uint64
MetricFunc extracts a comparable weight value from QueryStats. Higher values mean "heavier" query.
func ResolveMetricFunc ¶
func ResolveMetricFunc(metricName string) (MetricFunc, error)
ResolveMetricFunc returns the MetricFunc for the given metric name. An empty string defaults to "fetched_samples".
type QueryEntry ¶
type QueryEntry struct {
QueryID uint64
Cancel context.CancelFunc
Stats *querier_stats.QueryStats
QueryExpr string // PromQL expression for logging
UserID string // tenant ID for logging/metrics
RequestID string // request ID for correlation
RegisteredAt time.Time
}
QueryEntry represents a single running query in the registry.
type QueryEvictor ¶
QueryEvictor monitors system-wide resource utilization and evicts the heaviest running query when thresholds are breached.
func NewQueryEvictor ¶
func NewQueryEvictor( monitor resource.IMonitor, registry *QueryRegistry, cfg configs.EvictionConfig, logger log.Logger, reg prometheus.Registerer, component string, ) *QueryEvictor
NewQueryEvictor creates a new evictor. Returns nil if config is disabled.
type QueryRegistry ¶
type QueryRegistry struct {
// contains filtered or unexported fields
}
QueryRegistry tracks all currently running queries.
func NewQueryRegistry ¶
func NewQueryRegistry(metric MetricFunc) *QueryRegistry
NewQueryRegistry creates a registry with the given metric function.
func (*QueryRegistry) Deregister ¶
func (r *QueryRegistry) Deregister(id uint64)
Deregister removes a query from the registry. It is a no-op if the ID is not found.
func (*QueryRegistry) FindHeaviest ¶
func (r *QueryRegistry) FindHeaviest(n int, minAge time.Duration) []*QueryEntry
FindHeaviest returns up to n entries with the highest metric values among queries that have been running for at least minAge, sorted heaviest first. Returns nil if no eligible queries exist.
func (*QueryRegistry) Len ¶
func (r *QueryRegistry) Len() int
Len returns the number of currently registered queries.
func (*QueryRegistry) Register ¶
func (r *QueryRegistry) Register(cancel context.CancelFunc, stats *querier_stats.QueryStats, queryExpr string, userID string, requestID string) uint64
Register adds a running query and returns its unique, monotonically increasing ID.
type ResourceEvictingEngine ¶
type ResourceEvictingEngine struct {
// contains filtered or unexported fields
}
ResourceEvictingEngine wraps a QueryEngine to register running queries with a QueryRegistry, enabling resource-based eviction.
func NewResourceEvictingEngine ¶
func NewResourceEvictingEngine(inner engine.QueryEngine, registry *QueryRegistry) *ResourceEvictingEngine
NewResourceEvictingEngine wraps the given engine. If registry is nil, the wrapper is a no-op passthrough.