Documentation
¶
Index ¶
- Constants
- func AddBlockStoreTypeToContext(ctx context.Context, storeType string) context.Context
- func ConvertToChunks(t *testing.T, samples []cortexpb.Sample, histograms []*cortexpb.Histogram) []client.Chunk
- func DefaultLimitsConfig() validation.Limits
- func EnableExperimentalPromQLFunctions(enablePromQLExperimentalFunctions, enableHoltWinters bool)
- func ExtractBlocksFromContext(ctx context.Context) ([]*bucketindex.Block, bool)
- func InjectBlocksIntoContext(ctx context.Context, blocks ...*bucketindex.Block) context.Context
- func MetadataHandler(m MetadataQuerier) http.Handler
- func New(cfg Config, limits *validation.Overrides, distributor Distributor, ...) (storage.SampleAndChunkQueryable, storage.ExemplarQueryable, engine.QueryEngine)
- func NewErrorTranslateQueryable(q storage.Queryable) storage.Queryable
- func NewErrorTranslateQueryableWithFn(q storage.Queryable, fn ErrTranslateFn) storage.Queryable
- func NewErrorTranslateSampleAndChunkQueryable(q storage.SampleAndChunkQueryable) storage.SampleAndChunkQueryable
- func NewErrorTranslateSampleAndChunkQueryableWithFn(q storage.SampleAndChunkQueryable, fn ErrTranslateFn) storage.SampleAndChunkQueryable
- func NewParquetQueryable(config Config, storageCfg cortex_tsdb.BlocksStorageConfig, ...) (storage.Queryable, error)
- func NewQueryable(distributor QueryableWithFilter, stores []QueryableWithFilter, cfg Config, ...) storage.Queryable
- func NewSampleAndChunkQueryable(q storage.Queryable) storage.SampleAndChunkQueryable
- func RemoteReadHandler(q storage.Queryable, logger log.Logger) http.Handler
- func StatsRenderer(ctx context.Context, promStat *prom_stats.Statistics, param string) prom_stats.QueryStats
- func TranslateToPromqlAPIError(err error) error
- type BlocksConsistencyChecker
- type BlocksFinder
- type BlocksStoreClient
- type BlocksStoreLimits
- type BlocksStoreQueryable
- type BlocksStoreSet
- type BucketIndexBlocksFinder
- type BucketIndexBlocksFinderConfig
- type BucketScanBlocksFinder
- type BucketScanBlocksFinderConfig
- type Cache
- type ClientConfig
- type Config
- type Distributor
- type DummyAlertmanagerRetriever
- type DummyRulesRetriever
- type DummyTargetRetriever
- type ErrTranslateFn
- type MetadataQuerier
- type MockDistributor
- func (m *MockDistributor) LabelNames(ctx context.Context, from model.Time, to model.Time, hints *storage.LabelHints, ...) ([]string, error)
- func (m *MockDistributor) LabelNamesStream(ctx context.Context, from model.Time, to model.Time, hints *storage.LabelHints, ...) ([]string, error)
- func (m *MockDistributor) LabelValuesForLabelName(ctx context.Context, from, to model.Time, lbl model.LabelName, ...) ([]string, error)
- func (m *MockDistributor) LabelValuesForLabelNameStream(ctx context.Context, from, to model.Time, lbl model.LabelName, ...) ([]string, error)
- func (m *MockDistributor) MetricsForLabelMatchers(ctx context.Context, from, to model.Time, hints *storage.SelectHints, ...) ([]labels.Labels, error)
- func (m *MockDistributor) MetricsForLabelMatchersStream(ctx context.Context, from, to model.Time, hints *storage.SelectHints, ...) ([]labels.Labels, error)
- func (m *MockDistributor) MetricsMetadata(ctx context.Context, request *client.MetricsMetadataRequest) ([]scrape.MetricMetadata, error)
- func (m *MockDistributor) QueryExemplars(ctx context.Context, from, to model.Time, matchers ...[]*labels.Matcher) (*client.ExemplarQueryResponse, error)
- func (m *MockDistributor) QueryStream(ctx context.Context, from, to model.Time, partialDataEnabled bool, ...) (*client.QueryStreamResponse, error)
- type MockLimitingDistributor
- type QueryableWithFilter
- type TestConfig
Constants ¶
const BlockStoreTypeHeader = "X-Cortex-BlockStore-Type"
Variables ¶
This section is empty.
Functions ¶
func AddBlockStoreTypeToContext ¶ added in v1.20.0
AddBlockStoreTypeToContext checks HTTP header and set block store key to context if relevant header is set.
func ConvertToChunks ¶ added in v1.18.0
func DefaultLimitsConfig ¶ added in v1.11.0
func DefaultLimitsConfig() validation.Limits
func EnableExperimentalPromQLFunctions ¶ added in v1.20.0
func EnableExperimentalPromQLFunctions(enablePromQLExperimentalFunctions, enableHoltWinters bool)
func ExtractBlocksFromContext ¶ added in v1.20.0
func ExtractBlocksFromContext(ctx context.Context) ([]*bucketindex.Block, bool)
func InjectBlocksIntoContext ¶ added in v1.20.0
func MetadataHandler ¶ added in v1.1.0
func MetadataHandler(m MetadataQuerier) http.Handler
MetadataHandler returns metric metadata held by Cortex for a given tenant. It is kept and returned as a set.
func New ¶
func New(cfg Config, limits *validation.Overrides, distributor Distributor, stores []QueryableWithFilter, reg prometheus.Registerer, logger log.Logger, isPartialDataEnabled partialdata.IsCfgEnabledFunc) (storage.SampleAndChunkQueryable, storage.ExemplarQueryable, engine.QueryEngine)
New builds a queryable and promql engine.
func NewErrorTranslateQueryable ¶ added in v1.10.0
func NewErrorTranslateQueryableWithFn ¶ added in v1.11.0
func NewErrorTranslateQueryableWithFn(q storage.Queryable, fn ErrTranslateFn) storage.Queryable
func NewErrorTranslateSampleAndChunkQueryable ¶ added in v1.11.0
func NewErrorTranslateSampleAndChunkQueryable(q storage.SampleAndChunkQueryable) storage.SampleAndChunkQueryable
func NewErrorTranslateSampleAndChunkQueryableWithFn ¶ added in v1.11.0
func NewErrorTranslateSampleAndChunkQueryableWithFn(q storage.SampleAndChunkQueryable, fn ErrTranslateFn) storage.SampleAndChunkQueryable
func NewParquetQueryable ¶ added in v1.20.0
func NewParquetQueryable( config Config, storageCfg cortex_tsdb.BlocksStorageConfig, limits *validation.Overrides, blockStorageQueryable *BlocksStoreQueryable, logger log.Logger, reg prometheus.Registerer, ) (storage.Queryable, error)
func NewQueryable ¶
func NewQueryable(distributor QueryableWithFilter, stores []QueryableWithFilter, cfg Config, limits *validation.Overrides) storage.Queryable
NewQueryable creates a new Queryable for cortex.
func NewSampleAndChunkQueryable ¶ added in v1.7.0
func NewSampleAndChunkQueryable(q storage.Queryable) storage.SampleAndChunkQueryable
NewSampleAndChunkQueryable creates a SampleAndChunkQueryable from a Queryable with a ChunkQueryable stub, that errors once it gets called.
func RemoteReadHandler ¶
RemoteReadHandler handles Prometheus remote read requests.
func StatsRenderer ¶ added in v1.19.0
func StatsRenderer(ctx context.Context, promStat *prom_stats.Statistics, param string) prom_stats.QueryStats
func TranslateToPromqlAPIError ¶ added in v1.10.0
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 503 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 BlocksConsistencyChecker ¶ added in v1.2.0
type BlocksConsistencyChecker struct {
// contains filtered or unexported fields
}
func NewBlocksConsistencyChecker ¶ added in v1.2.0
func NewBlocksConsistencyChecker(uploadGracePeriod, deletionGracePeriod time.Duration, logger log.Logger, reg prometheus.Registerer) *BlocksConsistencyChecker
func (*BlocksConsistencyChecker) Check ¶ added in v1.2.0
func (c *BlocksConsistencyChecker) Check(knownBlocks bucketindex.Blocks, knownDeletionMarks map[ulid.ULID]*bucketindex.BlockDeletionMark, queriedBlocks []ulid.ULID) (missingBlocks []ulid.ULID)
type BlocksFinder ¶ added in v1.1.0
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, matchers []*labels.Matcher) (bucketindex.Blocks, map[ulid.ULID]*bucketindex.BlockDeletionMark, error)
}
BlocksFinder is the interface used to find blocks for a given user and time range.
type BlocksStoreClient ¶ added in v1.2.0
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 ¶ added in v1.3.0
type BlocksStoreLimits interface {
bucket.TenantConfigProvider
MaxChunksPerQueryFromStore(userID string) int
StoreGatewayTenantShardSize(userID string) float64
}
BlocksStoreLimits is the interface that should be implemented by the limits provider.
type BlocksStoreQueryable ¶ added in v1.1.0
BlocksStoreQueryable is a queryable which queries blocks storage via the store-gateway.
func NewBlocksStoreQueryable ¶ added in v1.1.0
func NewBlocksStoreQueryable( stores BlocksStoreSet, finder BlocksFinder, consistency *BlocksConsistencyChecker, limits BlocksStoreLimits, config Config, logger log.Logger, reg prometheus.Registerer, ) (*BlocksStoreQueryable, error)
func NewBlocksStoreQueryableFromConfig ¶ added in v1.1.0
func NewBlocksStoreQueryableFromConfig(querierCfg Config, gatewayCfg storegateway.Config, storageCfg cortex_tsdb.BlocksStorageConfig, limits BlocksStoreLimits, logger log.Logger, reg prometheus.Registerer) (*BlocksStoreQueryable, error)
type BlocksStoreSet ¶ added in v1.1.0
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, attemptedBlocksZones map[ulid.ULID]map[string]int) (map[BlocksStoreClient][]ulid.ULID, error)
}
BlocksStoreSet is the interface used to get the clients to query series on a set of blocks.
type BucketIndexBlocksFinder ¶ added in v1.7.0
BucketIndexBlocksFinder implements BlocksFinder interface and find blocks in the bucket looking up the bucket index.
func NewBucketIndexBlocksFinder ¶ added in v1.7.0
func NewBucketIndexBlocksFinder(cfg BucketIndexBlocksFinderConfig, bkt objstore.Bucket, cfgProvider bucket.TenantConfigProvider, logger log.Logger, reg prometheus.Registerer) *BucketIndexBlocksFinder
func (*BucketIndexBlocksFinder) GetBlocks ¶ added in v1.7.0
func (f *BucketIndexBlocksFinder) GetBlocks(ctx context.Context, userID string, minT, maxT int64, _ []*labels.Matcher) (bucketindex.Blocks, map[ulid.ULID]*bucketindex.BlockDeletionMark, error)
GetBlocks implements BlocksFinder.
type BucketIndexBlocksFinderConfig ¶ added in v1.7.0
type BucketIndexBlocksFinderConfig struct {
IndexLoader bucketindex.LoaderConfig
MaxStalePeriod time.Duration
IgnoreDeletionMarksDelay time.Duration
IgnoreBlocksWithin time.Duration
}
type BucketScanBlocksFinder ¶ added in v1.7.0
BucketScanBlocksFinder is a BlocksFinder implementation periodically scanning the bucket to discover blocks.
func NewBucketScanBlocksFinder ¶ added in v1.7.0
func NewBucketScanBlocksFinder(cfg BucketScanBlocksFinderConfig, usersScanner users.Scanner, bucketClient objstore.InstrumentedBucket, cfgProvider bucket.TenantConfigProvider, logger log.Logger, reg prometheus.Registerer) *BucketScanBlocksFinder
func (*BucketScanBlocksFinder) GetBlocks ¶ added in v1.7.0
func (d *BucketScanBlocksFinder) GetBlocks(_ context.Context, userID string, minT, maxT int64, _ []*labels.Matcher) (bucketindex.Blocks, map[ulid.ULID]*bucketindex.BlockDeletionMark, error)
GetBlocks returns known blocks for userID containing samples within the range minT and maxT (milliseconds, both included). Returned blocks are sorted by MaxTime descending.
type BucketScanBlocksFinderConfig ¶ added in v1.7.0
type Cache ¶ added in v1.20.0
type Cache[T any] struct { // contains filtered or unexported fields }
type ClientConfig ¶ added in v1.8.0
type ClientConfig struct {
TLSEnabled bool `yaml:"tls_enabled"`
TLS tls.ClientConfig `yaml:",inline"`
GRPCCompression string `yaml:"grpc_compression"`
HealthCheckConfig grpcclient.HealthCheckConfig `` /* 179-byte string literal not displayed */
ConnectTimeout time.Duration `yaml:"connect_timeout"`
}
func (*ClientConfig) RegisterFlagsWithPrefix ¶ added in v1.8.0
func (cfg *ClientConfig) RegisterFlagsWithPrefix(prefix string, f *flag.FlagSet)
type Config ¶
type Config struct {
MaxConcurrent int `yaml:"max_concurrent"`
Timeout time.Duration `yaml:"timeout"`
IngesterStreaming bool `yaml:"ingester_streaming" doc:"hidden"`
IngesterMetadataStreaming bool `yaml:"ingester_metadata_streaming"`
IngesterLabelNamesWithMatchers bool `yaml:"ingester_label_names_with_matchers"`
MaxSamples int `yaml:"max_samples"`
QueryIngestersWithin time.Duration `yaml:"query_ingesters_within"`
EnablePerStepStats bool `yaml:"per_step_stats_enabled"`
// Use compression for metrics query API or instant and range query APIs.
ResponseCompression string `yaml:"response_compression"`
// QueryStoreAfter the time after which queries should also be sent to the store and not just ingesters.
QueryStoreAfter time.Duration `yaml:"query_store_after"`
MaxQueryIntoFuture time.Duration `yaml:"max_query_into_future"`
// The default evaluation interval for the promql engine.
// Needs to be configured for subqueries to work as it is the default
// step if not specified.
DefaultEvaluationInterval time.Duration `yaml:"default_evaluation_interval"`
// Limit of number of steps allowed for every subquery expression in a query.
MaxSubQuerySteps int64 `yaml:"max_subquery_steps"`
// Directory for ActiveQueryTracker. If empty, ActiveQueryTracker will be disabled and MaxConcurrent will not be applied (!).
// ActiveQueryTracker logs queries that were active during the last crash, but logs them on the next startup.
// However, we need to use active query tracker, otherwise we cannot limit Max Concurrent queries in the PromQL
// engine.
ActiveQueryTrackerDir string `yaml:"active_query_tracker_dir"`
// LookbackDelta determines the time since the last sample after which a time
// series is considered stale.
LookbackDelta time.Duration `yaml:"lookback_delta"`
// Blocks storage only.
StoreGatewayAddresses string `yaml:"store_gateway_addresses"`
StoreGatewayClient ClientConfig `yaml:"store_gateway_client"`
StoreGatewayQueryStatsEnabled bool `yaml:"store_gateway_query_stats"`
// The maximum number of times we attempt fetching missing blocks from different Store Gateways.
StoreGatewayConsistencyCheckMaxAttempts int `yaml:"store_gateway_consistency_check_max_attempts"`
// The maximum number of times we attempt fetching data from Ingesters.
IngesterQueryMaxAttempts int `yaml:"ingester_query_max_attempts"`
ShuffleShardingIngestersLookbackPeriod time.Duration `yaml:"shuffle_sharding_ingesters_lookback_period"`
ThanosEngine engine.ThanosEngineConfig `yaml:"thanos_engine"`
// Ignore max query length check at Querier.
IgnoreMaxQueryLength bool `yaml:"ignore_max_query_length"`
EnablePromQLExperimentalFunctions bool `yaml:"enable_promql_experimental_functions"`
// Query Parquet files if available
EnableParquetQueryable bool `yaml:"enable_parquet_queryable"`
ParquetQueryableShardCacheSize int `yaml:"parquet_queryable_shard_cache_size"`
ParquetQueryableDefaultBlockStore string `yaml:"parquet_queryable_default_block_store"`
ParquetQueryableFallbackDisabled bool `yaml:"parquet_queryable_fallback_disabled"`
DistributedExecEnabled bool `yaml:"distributed_exec_enabled" doc:"hidden"`
}
Config contains the configuration require to create a querier
func DefaultQuerierConfig ¶ added in v1.11.0
func DefaultQuerierConfig() Config
func (*Config) GetStoreGatewayAddresses ¶ added in v1.1.0
func (*Config) RegisterFlags ¶
RegisterFlags adds the flags required to config this to the given FlagSet.
type Distributor ¶
type Distributor interface {
QueryStream(ctx context.Context, from, to model.Time, partialDataEnabled bool, matchers ...*labels.Matcher) (*client.QueryStreamResponse, 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, hint *storage.LabelHints, partialDataEnabled bool, matchers ...*labels.Matcher) ([]string, error)
LabelValuesForLabelNameStream(ctx context.Context, from, to model.Time, label model.LabelName, hint *storage.LabelHints, partialDataEnabled bool, matchers ...*labels.Matcher) ([]string, error)
LabelNames(context.Context, model.Time, model.Time, *storage.LabelHints, bool, ...*labels.Matcher) ([]string, error)
LabelNamesStream(context.Context, model.Time, model.Time, *storage.LabelHints, bool, ...*labels.Matcher) ([]string, error)
MetricsForLabelMatchers(ctx context.Context, from, through model.Time, hint *storage.SelectHints, partialDataEnabled bool, matchers ...*labels.Matcher) ([]labels.Labels, error)
MetricsForLabelMatchersStream(ctx context.Context, from, through model.Time, hint *storage.SelectHints, partialDataEnabled bool, matchers ...*labels.Matcher) ([]labels.Labels, error)
MetricsMetadata(ctx context.Context, req *client.MetricsMetadataRequest) ([]scrape.MetricMetadata, 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.
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 ¶ added in v1.16.0
func (DummyTargetRetriever) TargetsDroppedCounts() map[string]int
TargetsDroppedCounts implements targetRetriever.
type ErrTranslateFn ¶ added in v1.11.0
ErrTranslateFn is used to translate or wrap error before returning it by functions in storage.SampleAndChunkQueryable interface. Input error may be nil.
type MetadataQuerier ¶ added in v1.19.0
type MetadataQuerier interface {
MetricsMetadata(ctx context.Context, req *client.MetricsMetadataRequest) ([]scrape.MetricMetadata, error)
}
type MockDistributor ¶ added in v1.11.0
func (*MockDistributor) LabelNames ¶ added in v1.11.0
func (*MockDistributor) LabelNamesStream ¶ added in v1.13.0
func (*MockDistributor) LabelValuesForLabelName ¶ added in v1.11.0
func (*MockDistributor) LabelValuesForLabelNameStream ¶ added in v1.13.0
func (*MockDistributor) MetricsForLabelMatchers ¶ added in v1.11.0
func (*MockDistributor) MetricsForLabelMatchersStream ¶ added in v1.13.0
func (*MockDistributor) MetricsMetadata ¶ added in v1.11.0
func (m *MockDistributor) MetricsMetadata(ctx context.Context, request *client.MetricsMetadataRequest) ([]scrape.MetricMetadata, error)
func (*MockDistributor) QueryExemplars ¶ added in v1.11.0
func (m *MockDistributor) QueryExemplars(ctx context.Context, from, to model.Time, matchers ...[]*labels.Matcher) (*client.ExemplarQueryResponse, error)
func (*MockDistributor) QueryStream ¶ added in v1.11.0
type MockLimitingDistributor ¶ added in v1.16.0
type MockLimitingDistributor struct {
MockDistributor
// contains filtered or unexported fields
}
func (*MockLimitingDistributor) QueryStream ¶ added in v1.16.0
type QueryableWithFilter ¶ added in v1.3.0
type QueryableWithFilter interface {
storage.Queryable
// UseQueryable returns true if this queryable should be used to satisfy the query for given time range.
// Query min and max time are in milliseconds since epoch.
UseQueryable(now time.Time, queryMinT, queryMaxT int64) bool
}
QueryableWithFilter extends Queryable interface with `UseQueryable` filtering function.
func UseAlwaysQueryable ¶ added in v1.3.0
func UseAlwaysQueryable(q storage.Queryable) QueryableWithFilter
Wraps storage.Queryable into QueryableWithFilter, with no query filtering.
func UseBeforeTimestampQueryable ¶ added in v1.3.0
func UseBeforeTimestampQueryable(queryable storage.Queryable, ts time.Time) QueryableWithFilter
Returns QueryableWithFilter, that is used only if query starts before given timestamp. If timestamp is zero (time.IsZero), queryable is always used.
type TestConfig ¶ added in v1.11.0
type TestConfig struct {
Cfg Config
Distributor Distributor
Stores []QueryableWithFilter
}
Source Files
¶
- block.go
- blocks_consistency_checker.go
- blocks_finder_bucket_index.go
- blocks_finder_bucket_scan.go
- blocks_store_balanced_set.go
- blocks_store_queryable.go
- blocks_store_replicated_set.go
- bucket.go
- chunk_store_queryable.go
- distributor_queryable.go
- dummy.go
- error_translate_queryable.go
- metadata_handler.go
- parquet_queryable.go
- querier.go
- remote_read.go
- stats_renderer.go
- store_gateway_client.go
- testutils.go