Help us shape the future of Go! Take the 2026 Go Developer Survey

queryfrontend

package
v0.26.0 Latest Latest
Warning

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

Go to latest
Published: Apr 9, 2022 License: Apache-2.0 Imports: 45 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidLengthResponse        = fmt.Errorf("proto: negative length found during unmarshaling")
	ErrIntOverflowResponse          = fmt.Errorf("proto: integer overflow")
	ErrUnexpectedEndOfGroupResponse = fmt.Errorf("proto: unexpected end of group")
)
View Source
var (

	// DefaultRedisConfig is default redis config for queryfrontend.
	DefaultRedisConfig = RedisResponseCacheConfig{
		Redis:      cacheutil.DefaultRedisClientConfig,
		Expiration: 24 * time.Hour,
	}
)

Functions

func DownsampledMiddleware

func DownsampledMiddleware(merger queryrange.Merger, registerer prometheus.Registerer) queryrange.Middleware

DownsampledMiddleware creates a new Middleware that requests downsampled data should response to original request with auto max_source_resolution not contain data points.

func NewCacheConfig

func NewCacheConfig(logger log.Logger, confContentYaml []byte) (*cortexcache.Config, error)

NewCacheConfig is a parser that converts a Thanos cache config yaml into a cortex cache config struct.

func NewThanosLabelsCodec

func NewThanosLabelsCodec(partialResponse bool, defaultMetadataTimeRange time.Duration) *labelsCodec

NewThanosLabelsCodec initializes a labelsCodec.

func NewThanosQueryRangeCodec

func NewThanosQueryRangeCodec(partialResponse bool) *queryRangeCodec

NewThanosQueryRangeCodec initializes a queryRangeCodec.

func NewTripperware

func NewTripperware(config Config, reg prometheus.Registerer, logger log.Logger) (queryrange.Tripperware, error)

NewTripperware returns a Tripperware which sends requests to different sub tripperwares based on the query type.

func SplitByIntervalMiddleware

func SplitByIntervalMiddleware(interval queryrange.IntervalFn, limits queryrange.Limits, merger queryrange.Merger, registerer prometheus.Registerer) queryrange.Middleware

SplitByIntervalMiddleware creates a new Middleware that splits requests by a given interval.

Types

type CacheProviderConfig

type CacheProviderConfig struct {
	Type   ResponseCacheProvider `yaml:"type"`
	Config interface{}           `yaml:"config"`
}

CacheProviderConfig is the initial CacheProviderConfig struct holder before parsing it into a specific cache provider. Based on the config type the config is then parsed into a specific cache provider.

type Config

type Config struct {
	QueryRangeConfig
	LabelsConfig
	DownstreamTripperConfig

	CortexHandlerConfig    *transport.HandlerConfig
	CompressResponses      bool
	CacheCompression       string
	RequestLoggingDecision string
	DownstreamURL          string
	ForwardHeaders         []string
}

Config holds the query frontend configs.

func (*Config) Validate

func (cfg *Config) Validate() error

Validate a fully initialized config.

type DownstreamTripperConfig

type DownstreamTripperConfig struct {
	IdleConnTimeout       prommodel.Duration `yaml:"idle_conn_timeout"`
	ResponseHeaderTimeout prommodel.Duration `yaml:"response_header_timeout"`
	TLSHandshakeTimeout   prommodel.Duration `yaml:"tls_handshake_timeout"`
	ExpectContinueTimeout prommodel.Duration `yaml:"expect_continue_timeout"`
	MaxIdleConns          *int               `yaml:"max_idle_conns"`
	MaxIdleConnsPerHost   *int               `yaml:"max_idle_conns_per_host"`
	MaxConnsPerHost       *int               `yaml:"max_conns_per_host"`

	CachePathOrContent extflag.PathOrContent
}

DownstreamTripperConfig stores the http.Transport configuration for query-frontend's HTTP downstream tripper.

type InMemoryResponseCacheConfig

type InMemoryResponseCacheConfig struct {
	// MaxSize represents overall maximum number of bytes cache can contain.
	MaxSize string `yaml:"max_size"`
	// MaxSizeItems represents the maximum number of entries in the cache.
	MaxSizeItems int `yaml:"max_size_items"`
	// Validity represents the expiry duration for the cache.
	Validity time.Duration `yaml:"validity"`
}

InMemoryResponseCacheConfig holds the configs for the in-memory cache provider.

type LabelsConfig

type LabelsConfig struct {
	// PartialResponseStrategy is the default strategy used
	// when parsing thanos query request.
	PartialResponseStrategy bool
	DefaultTimeRange        time.Duration

	ResultsCacheConfig *queryrange.ResultsCacheConfig
	CachePathOrContent extflag.PathOrContent

	SplitQueriesByInterval time.Duration
	MaxRetries             int

	Limits *cortexvalidation.Limits
}

LabelsConfig holds the config for labels tripperware.

type MemcachedResponseCacheConfig

type MemcachedResponseCacheConfig struct {
	Memcached cacheutil.MemcachedClientConfig `yaml:",inline"`
	// Expiration sets a global expiration limit for all cached items.
	Expiration time.Duration `yaml:"expiration"`
}

MemcachedResponseCacheConfig holds the configs for the memcache cache provider.

type QueryRangeConfig

type QueryRangeConfig struct {
	// PartialResponseStrategy is the default strategy used
	// when parsing thanos query request.
	PartialResponseStrategy bool

	ResultsCacheConfig *queryrange.ResultsCacheConfig
	CachePathOrContent extflag.PathOrContent

	AlignRangeWithStep     bool
	RequestDownsampled     bool
	SplitQueriesByInterval time.Duration
	MaxRetries             int
	Limits                 *cortexvalidation.Limits
}

QueryRangeConfig holds the config for query range tripperware.

type RedisResponseCacheConfig

type RedisResponseCacheConfig struct {
	Redis cacheutil.RedisClientConfig `yaml:",inline"`
	// Expiration sets a global expiration limit for all cached items.
	Expiration time.Duration `yaml:"expiration"`
}

RedisResponseCacheConfig holds the configs for the redis cache provider.

type RequestHeader

type RequestHeader struct {
	Name   string
	Values []string
}

type ResponseCacheProvider

type ResponseCacheProvider string
const (
	INMEMORY  ResponseCacheProvider = "IN-MEMORY"
	MEMCACHED ResponseCacheProvider = "MEMCACHED"
	REDIS     ResponseCacheProvider = "REDIS"
)

type ResponseHeader

type ResponseHeader struct {
	Name   string   `protobuf:"bytes,1,opt,name=Name,proto3" json:"-"`
	Values []string `protobuf:"bytes,2,rep,name=Values,proto3" json:"-"`
}

func (*ResponseHeader) Descriptor

func (*ResponseHeader) Descriptor() ([]byte, []int)

func (*ResponseHeader) Marshal

func (m *ResponseHeader) Marshal() (dAtA []byte, err error)

func (*ResponseHeader) MarshalTo

func (m *ResponseHeader) MarshalTo(dAtA []byte) (int, error)

func (*ResponseHeader) MarshalToSizedBuffer

func (m *ResponseHeader) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*ResponseHeader) ProtoMessage

func (*ResponseHeader) ProtoMessage()

func (*ResponseHeader) Reset

func (m *ResponseHeader) Reset()

func (*ResponseHeader) Size

func (m *ResponseHeader) Size() (n int)

func (*ResponseHeader) String

func (m *ResponseHeader) String() string

func (*ResponseHeader) Unmarshal

func (m *ResponseHeader) Unmarshal(dAtA []byte) error

func (*ResponseHeader) XXX_DiscardUnknown

func (m *ResponseHeader) XXX_DiscardUnknown()

func (*ResponseHeader) XXX_Marshal

func (m *ResponseHeader) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*ResponseHeader) XXX_Merge

func (m *ResponseHeader) XXX_Merge(src proto.Message)

func (*ResponseHeader) XXX_Size

func (m *ResponseHeader) XXX_Size() int

func (*ResponseHeader) XXX_Unmarshal

func (m *ResponseHeader) XXX_Unmarshal(b []byte) error

type ThanosLabelsRequest

type ThanosLabelsRequest struct {
	Start           int64
	End             int64
	Label           string
	Path            string
	Matchers        [][]*labels.Matcher
	StoreMatchers   [][]*labels.Matcher
	PartialResponse bool
	CachingOptions  queryrange.CachingOptions
	Headers         []*RequestHeader
}

func (*ThanosLabelsRequest) GetCachingOptions

func (r *ThanosLabelsRequest) GetCachingOptions() queryrange.CachingOptions

func (*ThanosLabelsRequest) GetEnd

func (r *ThanosLabelsRequest) GetEnd() int64

GetEnd returns the end timestamp of the request in milliseconds.

func (*ThanosLabelsRequest) GetQuery

func (r *ThanosLabelsRequest) GetQuery() string

GetQuery returns the query of the request.

func (*ThanosLabelsRequest) GetStart

func (r *ThanosLabelsRequest) GetStart() int64

GetStart returns the start timestamp of the request in milliseconds.

func (*ThanosLabelsRequest) GetStep

func (r *ThanosLabelsRequest) GetStep() int64

GetStep returns the step of the request in milliseconds. Returns 1 is a trick to avoid panic in https://github.com/cortexproject/cortex/blob/master/pkg/querier/queryrange/results_cache.go#L447.

func (*ThanosLabelsRequest) GetStoreMatchers

func (r *ThanosLabelsRequest) GetStoreMatchers() [][]*labels.Matcher

func (*ThanosLabelsRequest) LogToSpan

func (r *ThanosLabelsRequest) LogToSpan(sp opentracing.Span)

LogToSpan writes information about this request to an OpenTracing span.

func (*ThanosLabelsRequest) ProtoMessage

func (r *ThanosLabelsRequest) ProtoMessage()

ProtoMessage implements proto.Message interface required by queryrange.Request, which is not used in thanos.

func (*ThanosLabelsRequest) Reset

func (r *ThanosLabelsRequest) Reset()

Reset implements proto.Message interface required by queryrange.Request, which is not used in thanos.

func (*ThanosLabelsRequest) String

func (r *ThanosLabelsRequest) String() string

String implements proto.Message interface required by queryrange.Request, which is not used in thanos.

func (*ThanosLabelsRequest) WithQuery

func (r *ThanosLabelsRequest) WithQuery(_ string) queryrange.Request

WithQuery clone the current request with a different query.

func (*ThanosLabelsRequest) WithStartEnd

func (r *ThanosLabelsRequest) WithStartEnd(start, end int64) queryrange.Request

WithStartEnd clone the current request with different start and end timestamp.

type ThanosLabelsResponse

type ThanosLabelsResponse struct {
	Status    string            `protobuf:"bytes,1,opt,name=Status,proto3" json:"status"`
	Data      []string          `protobuf:"bytes,2,rep,name=Data,proto3" json:"data"`
	ErrorType string            `protobuf:"bytes,3,opt,name=ErrorType,proto3" json:"errorType,omitempty"`
	Error     string            `protobuf:"bytes,4,opt,name=Error,proto3" json:"error,omitempty"`
	Headers   []*ResponseHeader `protobuf:"bytes,5,rep,name=Headers,proto3" json:"-"`
}

func (*ThanosLabelsResponse) Descriptor

func (*ThanosLabelsResponse) Descriptor() ([]byte, []int)

func (*ThanosLabelsResponse) GetHeaders

GetHeaders returns the HTTP headers in the response.

func (*ThanosLabelsResponse) Marshal

func (m *ThanosLabelsResponse) Marshal() (dAtA []byte, err error)

func (*ThanosLabelsResponse) MarshalTo

func (m *ThanosLabelsResponse) MarshalTo(dAtA []byte) (int, error)

func (*ThanosLabelsResponse) MarshalToSizedBuffer

func (m *ThanosLabelsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*ThanosLabelsResponse) ProtoMessage

func (*ThanosLabelsResponse) ProtoMessage()

func (*ThanosLabelsResponse) Reset

func (m *ThanosLabelsResponse) Reset()

func (*ThanosLabelsResponse) Size

func (m *ThanosLabelsResponse) Size() (n int)

func (*ThanosLabelsResponse) String

func (m *ThanosLabelsResponse) String() string

func (*ThanosLabelsResponse) Unmarshal

func (m *ThanosLabelsResponse) Unmarshal(dAtA []byte) error

func (*ThanosLabelsResponse) XXX_DiscardUnknown

func (m *ThanosLabelsResponse) XXX_DiscardUnknown()

func (*ThanosLabelsResponse) XXX_Marshal

func (m *ThanosLabelsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*ThanosLabelsResponse) XXX_Merge

func (m *ThanosLabelsResponse) XXX_Merge(src proto.Message)

func (*ThanosLabelsResponse) XXX_Size

func (m *ThanosLabelsResponse) XXX_Size() int

func (*ThanosLabelsResponse) XXX_Unmarshal

func (m *ThanosLabelsResponse) XXX_Unmarshal(b []byte) error

type ThanosQueryRangeRequest

type ThanosQueryRangeRequest struct {
	Path                string
	Start               int64
	End                 int64
	Step                int64
	Timeout             time.Duration
	Query               string
	Dedup               bool
	PartialResponse     bool
	AutoDownsampling    bool
	MaxSourceResolution int64
	ReplicaLabels       []string
	StoreMatchers       [][]*labels.Matcher
	CachingOptions      queryrange.CachingOptions
	Headers             []*RequestHeader
}

func (*ThanosQueryRangeRequest) GetCachingOptions

func (r *ThanosQueryRangeRequest) GetCachingOptions() queryrange.CachingOptions

func (*ThanosQueryRangeRequest) GetEnd

func (r *ThanosQueryRangeRequest) GetEnd() int64

GetEnd returns the end timestamp of the request in milliseconds.

func (*ThanosQueryRangeRequest) GetQuery

func (r *ThanosQueryRangeRequest) GetQuery() string

GetQuery returns the query of the request.

func (*ThanosQueryRangeRequest) GetStart

func (r *ThanosQueryRangeRequest) GetStart() int64

GetStart returns the start timestamp of the request in milliseconds.

func (*ThanosQueryRangeRequest) GetStep

func (r *ThanosQueryRangeRequest) GetStep() int64

GetStep returns the step of the request in milliseconds.

func (*ThanosQueryRangeRequest) GetStoreMatchers

func (r *ThanosQueryRangeRequest) GetStoreMatchers() [][]*labels.Matcher

func (*ThanosQueryRangeRequest) LogToSpan

func (r *ThanosQueryRangeRequest) LogToSpan(sp opentracing.Span)

LogToSpan writes information about this request to an OpenTracing span.

func (*ThanosQueryRangeRequest) ProtoMessage

func (r *ThanosQueryRangeRequest) ProtoMessage()

ProtoMessage implements proto.Message interface required by queryrange.Request, which is not used in thanos.

func (*ThanosQueryRangeRequest) Reset

func (r *ThanosQueryRangeRequest) Reset()

Reset implements proto.Message interface required by queryrange.Request, which is not used in thanos.

func (*ThanosQueryRangeRequest) String

func (r *ThanosQueryRangeRequest) String() string

String implements proto.Message interface required by queryrange.Request, which is not used in thanos.

func (*ThanosQueryRangeRequest) WithQuery

func (r *ThanosQueryRangeRequest) WithQuery(query string) queryrange.Request

WithQuery clone the current request with a different query.

func (*ThanosQueryRangeRequest) WithStartEnd

func (r *ThanosQueryRangeRequest) WithStartEnd(start, end int64) queryrange.Request

WithStartEnd clone the current request with different start and end timestamp.

type ThanosRequest

type ThanosRequest interface {
	GetStoreMatchers() [][]*labels.Matcher
}

TODO(yeya24): add partial result when needed. ThanosRequest is a common interface defined for specific thanos requests.

type ThanosResponseExtractor

type ThanosResponseExtractor struct{}

ThanosResponseExtractor helps extracting specific info from Query Response.

func (ThanosResponseExtractor) Extract

Extract extracts response for specific a range from a response. This interface is not used for labels and series responses.

func (ThanosResponseExtractor) ResponseWithoutHeaders

func (ThanosResponseExtractor) ResponseWithoutHeaders(resp queryrange.Response) queryrange.Response

ResponseWithoutHeaders returns the response without HTTP headers.

type ThanosSeriesRequest

type ThanosSeriesRequest struct {
	Path            string
	Start           int64
	End             int64
	Dedup           bool
	PartialResponse bool
	ReplicaLabels   []string
	Matchers        [][]*labels.Matcher
	StoreMatchers   [][]*labels.Matcher
	CachingOptions  queryrange.CachingOptions
	Headers         []*RequestHeader
}

func (*ThanosSeriesRequest) GetCachingOptions

func (r *ThanosSeriesRequest) GetCachingOptions() queryrange.CachingOptions

func (*ThanosSeriesRequest) GetEnd

func (r *ThanosSeriesRequest) GetEnd() int64

GetEnd returns the end timestamp of the request in milliseconds.

func (*ThanosSeriesRequest) GetQuery

func (r *ThanosSeriesRequest) GetQuery() string

GetQuery returns the query of the request.

func (*ThanosSeriesRequest) GetStart

func (r *ThanosSeriesRequest) GetStart() int64

GetStart returns the start timestamp of the request in milliseconds.

func (*ThanosSeriesRequest) GetStep

func (r *ThanosSeriesRequest) GetStep() int64

GetStep returns the step of the request in milliseconds. Returns 1 is a trick to avoid panic in https://github.com/cortexproject/cortex/blob/master/pkg/querier/queryrange/results_cache.go#L447.

func (*ThanosSeriesRequest) GetStoreMatchers

func (r *ThanosSeriesRequest) GetStoreMatchers() [][]*labels.Matcher

func (*ThanosSeriesRequest) LogToSpan

func (r *ThanosSeriesRequest) LogToSpan(sp opentracing.Span)

LogToSpan writes information about this request to an OpenTracing span.

func (*ThanosSeriesRequest) ProtoMessage

func (r *ThanosSeriesRequest) ProtoMessage()

ProtoMessage implements proto.Message interface required by queryrange.Request, which is not used in thanos.

func (*ThanosSeriesRequest) Reset

func (r *ThanosSeriesRequest) Reset()

Reset implements proto.Message interface required by queryrange.Request, which is not used in thanos.

func (*ThanosSeriesRequest) String

func (r *ThanosSeriesRequest) String() string

String implements proto.Message interface required by queryrange.Request, which is not used in thanos.

func (*ThanosSeriesRequest) WithQuery

func (r *ThanosSeriesRequest) WithQuery(_ string) queryrange.Request

WithQuery clone the current request with a different query.

func (*ThanosSeriesRequest) WithStartEnd

func (r *ThanosSeriesRequest) WithStartEnd(start, end int64) queryrange.Request

WithStartEnd clone the current request with different start and end timestamp.

type ThanosSeriesResponse

type ThanosSeriesResponse struct {
	Status    string              `protobuf:"bytes,1,opt,name=Status,proto3" json:"status"`
	Data      []labelpb.ZLabelSet `protobuf:"bytes,2,rep,name=Data,proto3" json:"data"`
	ErrorType string              `protobuf:"bytes,3,opt,name=ErrorType,proto3" json:"errorType,omitempty"`
	Error     string              `protobuf:"bytes,4,opt,name=Error,proto3" json:"error,omitempty"`
	Headers   []*ResponseHeader   `protobuf:"bytes,5,rep,name=Headers,proto3" json:"-"`
}

func (*ThanosSeriesResponse) Descriptor

func (*ThanosSeriesResponse) Descriptor() ([]byte, []int)

func (*ThanosSeriesResponse) GetHeaders

GetHeaders returns the HTTP headers in the response.

func (*ThanosSeriesResponse) Marshal

func (m *ThanosSeriesResponse) Marshal() (dAtA []byte, err error)

func (*ThanosSeriesResponse) MarshalTo

func (m *ThanosSeriesResponse) MarshalTo(dAtA []byte) (int, error)

func (*ThanosSeriesResponse) MarshalToSizedBuffer

func (m *ThanosSeriesResponse) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*ThanosSeriesResponse) ProtoMessage

func (*ThanosSeriesResponse) ProtoMessage()

func (*ThanosSeriesResponse) Reset

func (m *ThanosSeriesResponse) Reset()

func (*ThanosSeriesResponse) Size

func (m *ThanosSeriesResponse) Size() (n int)

func (*ThanosSeriesResponse) String

func (m *ThanosSeriesResponse) String() string

func (*ThanosSeriesResponse) Unmarshal

func (m *ThanosSeriesResponse) Unmarshal(dAtA []byte) error

func (*ThanosSeriesResponse) XXX_DiscardUnknown

func (m *ThanosSeriesResponse) XXX_DiscardUnknown()

func (*ThanosSeriesResponse) XXX_Marshal

func (m *ThanosSeriesResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*ThanosSeriesResponse) XXX_Merge

func (m *ThanosSeriesResponse) XXX_Merge(src proto.Message)

func (*ThanosSeriesResponse) XXX_Size

func (m *ThanosSeriesResponse) XXX_Size() int

func (*ThanosSeriesResponse) XXX_Unmarshal

func (m *ThanosSeriesResponse) XXX_Unmarshal(b []byte) error

Jump to

Keyboard shortcuts

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