querier

package
v0.0.0-...-fbfa8e9 Latest Latest
Warning

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

Go to latest
Published: Dec 18, 2024 License: AGPL-3.0 Imports: 86 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Queries are a set of matchers with time ranges - should not get into megabytes
	MaxRemoteReadQuerySize = 1024 * 1024
)

Variables

This section is empty.

Functions

func ActiveNativeHistogramMetricsHandler

func ActiveNativeHistogramMetricsHandler(d Distributor, limits *validation.Overrides) http.Handler

func ActiveSeriesCardinalityHandler

func ActiveSeriesCardinalityHandler(d Distributor, limits *validation.Overrides) http.Handler

func LabelNamesCardinalityHandler

func LabelNamesCardinalityHandler(d Distributor, limits *validation.Overrides) http.Handler

LabelNamesCardinalityHandler creates handler for label names cardinality endpoint.

func LabelValuesCardinalityHandler

func LabelValuesCardinalityHandler(distributor Distributor, limits *validation.Overrides) http.Handler

LabelValuesCardinalityHandler creates handler for label values cardinality endpoint.

func New

New builds a queryable and promql engine.

func NewDistributorQueryable

func NewDistributorQueryable(distributor Distributor, cfgProvider distributorQueryableConfigProvider, queryMetrics *stats.QueryMetrics, logger log.Logger) storage.Queryable

func NewErrorTranslateQueryableWithFn

func NewErrorTranslateQueryableWithFn(q storage.Queryable, fn ErrTranslateFn) storage.Queryable

func NewMaxQueryLengthError

func NewMaxQueryLengthError(actualQueryLen, maxQueryLength time.Duration) validation.LimitError

func NewMetadataHandler

func NewMetadataHandler(m MetadataSupplier) http.Handler

NewMetadataHandler creates a http.Handler for serving metric metadata held by Mimir for a given tenant. It is kept and returned as a set.

func NewSampleAndChunkQueryable

func NewSampleAndChunkQueryable(q storage.Queryable) storage.SampleAndChunkQueryable

NewSampleAndChunkQueryable creates a SampleAndChunkQueryable from a Queryable.

func RemoteReadHandler

func RemoteReadHandler(q storage.SampleAndChunkQueryable, logger log.Logger) http.Handler

RemoteReadHandler handles Prometheus remote read requests.

func ShouldQueryBlockStore

func ShouldQueryBlockStore(queryStoreAfter time.Duration, now time.Time, queryMinT int64) bool

ShouldQueryBlockStore provides a check for whether the block store will be used for a given query.

func ShouldQueryIngesters

func ShouldQueryIngesters(queryIngestersWithin time.Duration, now time.Time, queryMaxT int64) bool

ShouldQueryIngesters provides a check for whether the ingesters will be used for a given query.

func TranslateToPromqlAPIError

func TranslateToPromqlAPIError(err error) error

TranslateToPromqlAPIError converts error to one of promql.Errors for consumption in PromQL API. PromQL API only recognizes few errors, and converts everything else to HTTP status code 422.

Specifically, it supports:

promql.ErrQueryCanceled, mapped to 499
promql.ErrQueryTimeout, mapped to 503
promql.ErrStorage mapped to 500
anything else is mapped to 422

Querier code produces different kinds of errors, and we want to map them to above-mentioned HTTP status codes correctly.

Details: - vendor/github.com/prometheus/prometheus/web/api/v1/api.go, respondError function only accepts *apiError types. - translation of error to *apiError happens in vendor/github.com/prometheus/prometheus/web/api/v1/api.go, returnAPIError method.

Types

type BlocksConsistency

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

func NewBlocksConsistency

func NewBlocksConsistency(uploadGracePeriod time.Duration, reg prometheus.Registerer) *BlocksConsistency

func (*BlocksConsistency) NewTracker

func (c *BlocksConsistency) NewTracker(knownBlocks bucketindex.Blocks, logger log.Logger) BlocksConsistencyTracker

NewTracker creates a consistency tracker from the known blocks. It filters out any block uploaded within uploadGracePeriod and with a deletion mark within deletionGracePeriod.

type BlocksConsistencyTracker

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

func (BlocksConsistencyTracker) Check

func (c BlocksConsistencyTracker) Check(queriedBlocks []ulid.ULID) (missingBlocks []ulid.ULID)

Check takes a slice of blocks which can be all queried blocks so far or only blocks queried since the last call to Check. Check returns the blocks which haven't been seen in any call to Check yet.

func (BlocksConsistencyTracker) Complete

func (c BlocksConsistencyTracker) Complete()

Complete should be called once the request tracked by this BlocksConsistencyTracker has been completed. This function should NOT be called if the request is canceled or interrupted due to any error.

type BlocksFinder

type BlocksFinder interface {
	services.Service

	// GetBlocks returns known blocks for userID containing samples within the range minT
	// and maxT (milliseconds, both included). Returned blocks are sorted by MaxTime descending.
	GetBlocks(ctx context.Context, userID string, minT, maxT int64) (bucketindex.Blocks, error)
}

BlocksFinder is the interface used to find blocks for a given user and time range.

type BlocksStoreClient

type BlocksStoreClient interface {
	storegatewaypb.StoreGatewayClient

	// RemoteAddress returns the address of the remote store-gateway and is used to uniquely
	// identify a store-gateway backend instance.
	RemoteAddress() string
}

BlocksStoreClient is the interface that should be implemented by any client used to query a backend store-gateway.

type BlocksStoreLimits

type BlocksStoreLimits interface {
	bucket.TenantConfigProvider

	MaxLabelsQueryLength(userID string) time.Duration
	MaxChunksPerQuery(userID string) int
	StoreGatewayTenantShardSize(userID string) int
}

BlocksStoreLimits is the interface that should be implemented by the limits provider.

type BlocksStoreQueryable

type BlocksStoreQueryable struct {
	services.Service
	// contains filtered or unexported fields
}

BlocksStoreQueryable is a queryable which queries blocks storage via the store-gateway.

func NewBlocksStoreQueryable

func NewBlocksStoreQueryable(
	stores BlocksStoreSet,
	finder BlocksFinder,
	consistency *BlocksConsistency,
	limits BlocksStoreLimits,
	queryStoreAfter time.Duration,
	streamingChunksBatchSize uint64,
	logger log.Logger,
	reg prometheus.Registerer,
) (*BlocksStoreQueryable, error)

func NewBlocksStoreQueryableFromConfig

func NewBlocksStoreQueryableFromConfig(querierCfg Config, gatewayCfg storegateway.Config, storageCfg mimir_tsdb.BlocksStorageConfig, limits BlocksStoreLimits, logger log.Logger, reg prometheus.Registerer) (*BlocksStoreQueryable, error)

func (*BlocksStoreQueryable) Querier

func (q *BlocksStoreQueryable) Querier(mint, maxt int64) (storage.Querier, error)

Querier returns a new Querier on the storage.

type BlocksStoreSet

type BlocksStoreSet interface {
	services.Service

	// GetClientsFor returns the store gateway clients that should be used to
	// query the set of blocks in input. The exclude parameter is the map of
	// blocks -> store-gateway addresses that should be excluded.
	GetClientsFor(userID string, blockIDs []ulid.ULID, exclude map[ulid.ULID][]string) (map[BlocksStoreClient][]ulid.ULID, error)
}

BlocksStoreSet is the interface used to get the clients to query series on a set of blocks.

type BucketIndexBlocksFinder

type BucketIndexBlocksFinder struct {
	services.Service
	// contains filtered or unexported fields
}

BucketIndexBlocksFinder implements BlocksFinder interface and find blocks in the bucket looking up the bucket index.

func (*BucketIndexBlocksFinder) GetBlocks

func (f *BucketIndexBlocksFinder) GetBlocks(ctx context.Context, userID string, minT, maxT int64) (bucketindex.Blocks, error)

GetBlocks implements BlocksFinder.

type BucketIndexBlocksFinderConfig

type BucketIndexBlocksFinderConfig struct {
	IndexLoader              bucketindex.LoaderConfig
	MaxStalePeriod           time.Duration
	IgnoreDeletionMarksDelay time.Duration
}

type ClientConfig

type ClientConfig struct {
	TLSEnabled bool             `yaml:"tls_enabled" category:"advanced"`
	TLS        tls.ClientConfig `yaml:",inline"`
}

func (*ClientConfig) RegisterFlagsWithPrefix

func (cfg *ClientConfig) RegisterFlagsWithPrefix(prefix string, f *flag.FlagSet)

type Config

type Config struct {
	// QueryStoreAfter the time after which queries should also be sent to the store and not just ingesters.
	QueryStoreAfter time.Duration `yaml:"query_store_after" category:"advanced"`

	StoreGatewayClient ClientConfig `yaml:"store_gateway_client"`

	ShuffleShardingIngestersEnabled bool `yaml:"shuffle_sharding_ingesters_enabled" category:"advanced"`

	PreferAvailabilityZone                         string        `yaml:"prefer_availability_zone" category:"experimental" doc:"hidden"`
	StreamingChunksPerIngesterSeriesBufferSize     uint64        `yaml:"streaming_chunks_per_ingester_series_buffer_size" category:"advanced"`
	StreamingChunksPerStoreGatewaySeriesBufferSize uint64        `yaml:"streaming_chunks_per_store_gateway_series_buffer_size" category:"advanced"`
	MinimizeIngesterRequests                       bool          `yaml:"minimize_ingester_requests" category:"advanced"`
	MinimiseIngesterRequestsHedgingDelay           time.Duration `yaml:"minimize_ingester_requests_hedging_delay" category:"advanced"`

	QueryEngine               string `yaml:"query_engine" category:"experimental"`
	EnableQueryEngineFallback bool   `yaml:"enable_query_engine_fallback" category:"experimental"`

	// PromQL engine config.
	EngineConfig engine.Config `yaml:",inline"`
}

Config contains the configuration require to create a querier

func (*Config) RegisterFlags

func (cfg *Config) RegisterFlags(f *flag.FlagSet)

RegisterFlags adds the flags required to config this to the given FlagSet.

func (*Config) Validate

func (cfg *Config) Validate() error

func (*Config) ValidateLimits

func (cfg *Config) ValidateLimits(limits validation.Limits) error

type Distributor

type Distributor interface {
	QueryStream(ctx context.Context, queryMetrics *stats.QueryMetrics, from, to model.Time, matchers ...*labels.Matcher) (client.CombinedQueryStreamResponse, error)
	QueryExemplars(ctx context.Context, from, to model.Time, matchers ...[]*labels.Matcher) (*client.ExemplarQueryResponse, error)
	LabelValuesForLabelName(ctx context.Context, from, to model.Time, label model.LabelName, matchers ...*labels.Matcher) ([]string, error)
	LabelNames(ctx context.Context, from model.Time, to model.Time, matchers ...*labels.Matcher) ([]string, error)
	MetricsForLabelMatchers(ctx context.Context, from, through model.Time, matchers ...*labels.Matcher) ([]labels.Labels, error)
	MetricsMetadata(ctx context.Context, req *client.MetricsMetadataRequest) ([]scrape.MetricMetadata, error)
	LabelNamesAndValues(ctx context.Context, matchers []*labels.Matcher, countMethod cardinality.CountMethod) (*client.LabelNamesAndValuesResponse, error)
	LabelValuesCardinality(ctx context.Context, labelNames []model.LabelName, matchers []*labels.Matcher, countMethod cardinality.CountMethod) (uint64, *client.LabelValuesCardinalityResponse, error)
	ActiveSeries(ctx context.Context, matchers []*labels.Matcher) ([]labels.Labels, error)
	ActiveNativeHistogramMetrics(ctx context.Context, matchers []*labels.Matcher) (*cardinality.ActiveNativeHistogramMetricsResponse, error)
}

Distributor is the read interface to the distributor, made an interface here to reduce package coupling.

type DummyAlertmanagerRetriever

type DummyAlertmanagerRetriever struct{}

DummyAlertmanagerRetriever implements AlertmanagerRetriever.

func (DummyAlertmanagerRetriever) Alertmanagers

func (DummyAlertmanagerRetriever) Alertmanagers() []*url.URL

Alertmanagers implements AlertmanagerRetriever.

func (DummyAlertmanagerRetriever) DroppedAlertmanagers

func (DummyAlertmanagerRetriever) DroppedAlertmanagers() []*url.URL

DroppedAlertmanagers implements AlertmanagerRetriever.

type DummyRulesRetriever

type DummyRulesRetriever struct{}

DummyRulesRetriever implements RulesRetriever.

func (DummyRulesRetriever) AlertingRules

func (DummyRulesRetriever) AlertingRules() []*rules.AlertingRule

AlertingRules implements RulesRetriever.

func (DummyRulesRetriever) RuleGroups

func (DummyRulesRetriever) RuleGroups() []*rules.Group

RuleGroups implements RulesRetriever.

type DummyTargetRetriever

type DummyTargetRetriever struct{}

DummyTargetRetriever implements github.com/prometheus/prometheus/web/api/v1.TargetRetriever. and v1.ScrapePoolsRetriever

func (DummyTargetRetriever) ScrapePools

func (DummyTargetRetriever) ScrapePools() []string

func (DummyTargetRetriever) TargetsActive

func (DummyTargetRetriever) TargetsActive() map[string][]*scrape.Target

TargetsActive implements TargetRetriever.

func (DummyTargetRetriever) TargetsDropped

func (DummyTargetRetriever) TargetsDropped() map[string][]*scrape.Target

TargetsDropped implements TargetRetriever.

func (DummyTargetRetriever) TargetsDroppedCounts

func (DummyTargetRetriever) TargetsDroppedCounts() map[string]int

TargetsDroppedCounts implements TargetRetriever.

type ErrTranslateFn

type ErrTranslateFn func(err error) error

ErrTranslateFn is used to translate or wrap error before returning it by functions in storage.SampleAndChunkQueryable interface. Input error may be nil.

type MetadataSupplier

type MetadataSupplier interface {
	MetricsMetadata(ctx context.Context, req *client.MetricsMetadataRequest) ([]scrape.MetricMetadata, error)
}

MetadataSupplier is the metadata specific part of the Distributor interface. It exists to allow us to wrap the default implementation (the distributor embedded in a querier) with logic for handling tenant federated metadata requests.

type SeriesWithChunks

type SeriesWithChunks interface {
	storage.Series

	// Returns all chunks with series data.
	Chunks() []chunk.Chunk
}

SeriesWithChunks extends storage.Series interface with direct access to Mimir chunks.

type TimeRangeQueryable

type TimeRangeQueryable struct {
	storage.Queryable
	IsApplicable func(tenantID string, now time.Time, queryMinT, queryMaxT int64, matchers ...*labels.Matcher) bool
	StorageName  string
}

TimeRangeQueryable is a Queryable that is aware of when it is applicable.

func NewStoreGatewayTimeRangeQueryable

func NewStoreGatewayTimeRangeQueryable(q storage.Queryable, querierConfig Config) TimeRangeQueryable

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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