querier

package
v0.0.0-...-e951c9a Latest Latest
Warning

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

Go to latest
Published: Oct 6, 2022 License: AGPL-3.0 Imports: 56 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultLimitsConfig

func DefaultLimitsConfig() validation.Limits

func InitWorkerService

func InitWorkerService(
	cfg WorkerServiceConfig,
	reg prometheus.Registerer,
	queryRoutesToHandlers map[string]http.Handler,
	alwaysExternalRoutesToHandlers map[string]http.Handler,
	externalRouter *mux.Router,
	externalHandler http.Handler,
	authMiddleware middleware.Interface,
) (serve services.Service, err error)

InitWorkerService takes a config object, a map of routes to handlers, an external http router and external http handler, and an auth middleware wrapper. This function creates an internal HTTP router that responds to all the provided query routes/handlers. This router can either be registered with the external Loki HTTP server, or be used internally by a querier worker so that it does not conflict with the routes registered by the Query Frontend module.

  1. Query-Frontend Enabled: If Loki has an All or QueryFrontend target, the internal HTTP router is wrapped with Tenant ID parsing middleware and passed to the frontend worker.

  2. Querier Standalone: The querier will register the internal HTTP router with the external HTTP router for the Prometheus API routes. Then the external HTTP server will be passed as a http.Handler to the frontend worker.

func WrapQuerySpanAndTimeout

func WrapQuerySpanAndTimeout(call string, q *QuerierAPI) middleware.Interface

WrapQuerySpanAndTimeout applies a context deadline and a span logger to a query call.

The timeout is based on the per-tenant query timeout configuration.

Types

type Config

type Config struct {
	TailMaxDuration               time.Duration    `yaml:"tail_max_duration"`
	ExtraQueryDelay               time.Duration    `yaml:"extra_query_delay,omitempty"`
	QueryIngestersWithin          time.Duration    `yaml:"query_ingesters_within,omitempty"`
	IngesterQueryStoreMaxLookback time.Duration    `yaml:"-"`
	Engine                        logql.EngineOpts `yaml:"engine,omitempty"`
	MaxConcurrent                 int              `yaml:"max_concurrent"`
	QueryStoreOnly                bool             `yaml:"query_store_only"`
	QueryIngesterOnly             bool             `yaml:"query_ingester_only"`
	MultiTenantQueriesEnabled     bool             `yaml:"multi_tenant_queries_enabled"`
	QueryTimeout                  time.Duration    `yaml:"query_timeout"`
}

Config for a querier.

func (*Config) RegisterFlags

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

RegisterFlags register flags.

func (*Config) Validate

func (cfg *Config) Validate() error

Validate validates the config.

type IngesterQuerier

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

IngesterQuerier helps with querying the ingesters.

func NewIngesterQuerier

func NewIngesterQuerier(clientCfg client.Config, ring ring.ReadRing, extraQueryDelay time.Duration) (*IngesterQuerier, error)

func (*IngesterQuerier) GetChunkIDs

func (q *IngesterQuerier) GetChunkIDs(ctx context.Context, from, through model.Time, matchers ...*labels.Matcher) ([]string, error)

func (*IngesterQuerier) Label

func (q *IngesterQuerier) Label(ctx context.Context, req *logproto.LabelRequest) ([][]string, error)

func (*IngesterQuerier) SelectLogs

func (q *IngesterQuerier) SelectLogs(ctx context.Context, params logql.SelectLogParams) ([]iter.EntryIterator, error)

func (*IngesterQuerier) SelectSample

func (q *IngesterQuerier) SelectSample(ctx context.Context, params logql.SelectSampleParams) ([]iter.SampleIterator, error)

func (*IngesterQuerier) Series

func (*IngesterQuerier) Stats

func (q *IngesterQuerier) Stats(ctx context.Context, userID string, from, through model.Time, matchers ...*labels.Matcher) (*index_stats.Stats, error)

func (*IngesterQuerier) Tail

func (*IngesterQuerier) TailDisconnectedIngesters

func (q *IngesterQuerier) TailDisconnectedIngesters(ctx context.Context, req *logproto.TailRequest, connectedIngestersAddr []string) (map[string]logproto.Querier_TailClient, error)

func (*IngesterQuerier) TailersCount

func (q *IngesterQuerier) TailersCount(ctx context.Context) ([]uint32, error)

type Metrics

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

func NewMetrics

func NewMetrics(r prometheus.Registerer) *Metrics

type MultiTenantQuerier

type MultiTenantQuerier struct {
	Querier
}

MultiTenantQuerier is able to query across different tenants.

func NewMultiTenantQuerier

func NewMultiTenantQuerier(querier Querier, logger log.Logger) *MultiTenantQuerier

NewMultiTenantQuerier returns a new querier able to query across different tenants.

func (*MultiTenantQuerier) IndexStats

func (q *MultiTenantQuerier) IndexStats(ctx context.Context, req *loghttp.RangeQuery) (*stats.Stats, error)

func (*MultiTenantQuerier) Label

func (*MultiTenantQuerier) SelectLogs

func (*MultiTenantQuerier) SelectSamples

func (*MultiTenantQuerier) Series

type Querier

Querier can select logs and samples and handle query requests.

type QuerierAPI

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

nolint // QuerierAPI defines HTTP handler functions for the querier.

func NewQuerierAPI

func NewQuerierAPI(cfg Config, querier Querier, limits *validation.Overrides, logger log.Logger) *QuerierAPI

NewQuerierAPI returns an instance of the QuerierAPI.

func (*QuerierAPI) IndexStatsHandler

func (q *QuerierAPI) IndexStatsHandler(w http.ResponseWriter, r *http.Request)

IndexStatsHandler queries the index for the data statistics related to a query

func (*QuerierAPI) InstantQueryHandler

func (q *QuerierAPI) InstantQueryHandler(w http.ResponseWriter, r *http.Request)

InstantQueryHandler is a http.HandlerFunc for instant queries.

func (*QuerierAPI) LabelHandler

func (q *QuerierAPI) LabelHandler(w http.ResponseWriter, r *http.Request)

LabelHandler is a http.HandlerFunc for handling label queries.

func (*QuerierAPI) LogQueryHandler

func (q *QuerierAPI) LogQueryHandler(w http.ResponseWriter, r *http.Request)

LogQueryHandler is a http.HandlerFunc for log only queries.

func (*QuerierAPI) RangeQueryHandler

func (q *QuerierAPI) RangeQueryHandler(w http.ResponseWriter, r *http.Request)

RangeQueryHandler is a http.HandlerFunc for range queries.

func (*QuerierAPI) SeriesHandler

func (q *QuerierAPI) SeriesHandler(w http.ResponseWriter, r *http.Request)

SeriesHandler returns the list of time series that match a certain label set. See https://prometheus.io/docs/prometheus/latest/querying/api/#finding-series-by-label-matchers

func (*QuerierAPI) TailHandler

func (q *QuerierAPI) TailHandler(w http.ResponseWriter, r *http.Request)

TailHandler is a http.HandlerFunc for handling tail queries.

type QueryResponse

type QueryResponse struct {
	ResultType parser.ValueType `json:"resultType"`
	Result     parser.Value     `json:"result"`
}

type SingleTenantQuerier

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

SingleTenantQuerier handles single tenant queries.

func New

func New(cfg Config, store storage.Store, ingesterQuerier *IngesterQuerier, limits *validation.Overrides, d deleteGetter, r prometheus.Registerer) (*SingleTenantQuerier, error)

New makes a new Querier.

func (*SingleTenantQuerier) Check

Check implements the grpc healthcheck

func (*SingleTenantQuerier) IndexStats

func (q *SingleTenantQuerier) IndexStats(ctx context.Context, req *loghttp.RangeQuery) (*stats.Stats, error)

func (*SingleTenantQuerier) Label

Label does the heavy lifting for a Label query.

func (*SingleTenantQuerier) SelectLogs

Select Implements logql.Querier which select logs via matchers and regex filters.

func (*SingleTenantQuerier) SelectSamples

func (*SingleTenantQuerier) Series

Series fetches any matching series for a list of matcher sets

func (*SingleTenantQuerier) Tail

Tail keeps getting matching logs from all ingesters for given query

type Tailer

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

Tailer manages complete lifecycle of a tail request

type TenantEntryIterator

type TenantEntryIterator struct {
	iter.EntryIterator
	// contains filtered or unexported fields
}

TenantEntry Iterator wraps an entry iterator and adds the tenant label.

func NewTenantEntryIterator

func NewTenantEntryIterator(iter iter.EntryIterator, id string) *TenantEntryIterator

func (*TenantEntryIterator) Labels

func (i *TenantEntryIterator) Labels() string

type TenantSampleIterator

type TenantSampleIterator struct {
	iter.SampleIterator
	// contains filtered or unexported fields
}

TenantEntry Iterator wraps a sample iterator and adds the tenant label.

func NewTenantSampleIterator

func NewTenantSampleIterator(iter iter.SampleIterator, id string) *TenantSampleIterator

func (*TenantSampleIterator) Labels

func (i *TenantSampleIterator) Labels() string

type WorkerServiceConfig

type WorkerServiceConfig struct {
	AllEnabled            bool
	ReadEnabled           bool
	GrpcListenPort        int
	QuerierMaxConcurrent  int
	QuerierWorkerConfig   *querier_worker.Config
	QueryFrontendEnabled  bool
	QuerySchedulerEnabled bool
	SchedulerRing         ring.ReadRing
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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