querysharding

package
v0.37.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 11, 2024 License: Apache-2.0 Imports: 5 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Analyzer added in v0.29.0

type Analyzer interface {
	Analyze(string) (QueryAnalysis, error)
}

type CachedQueryAnalyzer added in v0.29.0

type CachedQueryAnalyzer struct {
	// contains filtered or unexported fields
}

func NewQueryAnalyzer

func NewQueryAnalyzer() *CachedQueryAnalyzer

NewQueryAnalyzer creates a new QueryAnalyzer.

func (*CachedQueryAnalyzer) Analyze added in v0.29.0

func (a *CachedQueryAnalyzer) Analyze(query string) (QueryAnalysis, error)

type QueryAnalysis

type QueryAnalysis struct {
	// contains filtered or unexported fields
}

func (*QueryAnalysis) IsShardable

func (q *QueryAnalysis) IsShardable() bool

func (*QueryAnalysis) ShardBy

func (q *QueryAnalysis) ShardBy() bool

func (*QueryAnalysis) ShardingLabels

func (q *QueryAnalysis) ShardingLabels() []string

type QueryAnalyzer

type QueryAnalyzer struct{}

QueryAnalyzer is an analyzer which determines whether a PromQL Query is shardable and using which labels.

func (*QueryAnalyzer) Analyze

func (a *QueryAnalyzer) Analyze(query string) (QueryAnalysis, error)

Analyze uses the following algorithm:

  • if a query has functions which cannot be sharded such as absent or absent_over_time, then treat the query as non shardable.
  • if a query has functions `label_join` or `label_replace`, calculate the shard labels based on grouping labels.
  • Walk the query and find the least common labelset used in grouping expressions. If non-empty, treat the query as shardable by those labels.
  • otherwise, treat the query as non-shardable.

The le label is excluded from sharding.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL