Documentation ¶
Index ¶
- func DefaultLimitsConfig() validation.Limits
- func InitWorkerService(cfg WorkerServiceConfig, reg prometheus.Registerer, ...) (serve services.Service, err error)
- 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 TranslateToPromqlAPIError(err error) error
- type Config
- type DummyAlertmanagerRetriever
- type DummyRulesRetriever
- type DummyTargetRetriever
- type ErrTranslateFn
- type IngesterQuerier
- func (q *IngesterQuerier) GetChunkIDs(ctx context.Context, from, through model.Time, matchers ...*labels.Matcher) ([]string, error)
- func (q *IngesterQuerier) Label(ctx context.Context, req *logproto.LabelRequest) ([][]string, error)
- func (q *IngesterQuerier) SelectLogs(ctx context.Context, params logql.SelectLogParams) ([]iter.EntryIterator, error)
- func (q *IngesterQuerier) SelectSample(ctx context.Context, params logql.SelectSampleParams) ([]iter.SampleIterator, error)
- func (q *IngesterQuerier) Series(ctx context.Context, req *logproto.SeriesRequest) ([][]logproto.SeriesIdentifier, error)
- func (q *IngesterQuerier) Tail(ctx context.Context, req *logproto.TailRequest) (map[string]logproto.Querier_TailClient, error)
- func (q *IngesterQuerier) TailDisconnectedIngesters(ctx context.Context, req *logproto.TailRequest, ...) (map[string]logproto.Querier_TailClient, error)
- func (q *IngesterQuerier) TailersCount(ctx context.Context) ([]uint32, error)
- type MockDistributor
- func (m *MockDistributor) LabelNames(ctx context.Context, from, to model.Time) ([]string, error)
- func (m *MockDistributor) LabelValuesForLabelName(ctx context.Context, from, to model.Time, lbl model.LabelName, ...) ([]string, error)
- func (m *MockDistributor) MetricsForLabelMatchers(ctx context.Context, from, to model.Time, matchers ...*labels.Matcher) ([]metric.Metric, error)
- func (m *MockDistributor) MetricsMetadata(ctx context.Context) ([]scrape.MetricMetadata, error)
- func (m *MockDistributor) Query(ctx context.Context, from, to model.Time, matchers ...*labels.Matcher) (model.Matrix, 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, matchers ...*labels.Matcher) (*client.QueryStreamResponse, error)
- type Querier
- func (*Querier) Check(_ context.Context, _ *grpc_health_v1.HealthCheckRequest) (*grpc_health_v1.HealthCheckResponse, error)
- func (q *Querier) InstantQueryHandler(w http.ResponseWriter, r *http.Request)
- func (q *Querier) Label(ctx context.Context, req *logproto.LabelRequest) (*logproto.LabelResponse, error)
- func (q *Querier) LabelHandler(w http.ResponseWriter, r *http.Request)
- func (q *Querier) LogQueryHandler(w http.ResponseWriter, r *http.Request)
- func (q *Querier) RangeQueryHandler(w http.ResponseWriter, r *http.Request)
- func (q *Querier) SelectLogs(ctx context.Context, params logql.SelectLogParams) (iter.EntryIterator, error)
- func (q *Querier) SelectSamples(ctx context.Context, params logql.SelectSampleParams) (iter.SampleIterator, error)
- func (q *Querier) Series(ctx context.Context, req *logproto.SeriesRequest) (*logproto.SeriesResponse, error)
- func (q *Querier) SeriesHandler(w http.ResponseWriter, r *http.Request)
- func (q *Querier) SetQueryable(queryable logql.Querier)
- func (q *Querier) Tail(ctx context.Context, req *logproto.TailRequest) (*Tailer, error)
- func (q *Querier) TailHandler(w http.ResponseWriter, r *http.Request)
- type QueryResponse
- type Tailer
- type TestConfig
- type WorkerServiceConfig
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.
- 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.
- 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 NewErrorTranslateQueryableWithFn ¶
func NewErrorTranslateQueryableWithFn(q storage.Queryable, fn ErrTranslateFn) storage.Queryable
func NewErrorTranslateSampleAndChunkQueryable ¶
func NewErrorTranslateSampleAndChunkQueryable(q storage.SampleAndChunkQueryable) storage.SampleAndChunkQueryable
func NewErrorTranslateSampleAndChunkQueryableWithFn ¶
func NewErrorTranslateSampleAndChunkQueryableWithFn(q storage.SampleAndChunkQueryable, fn ErrTranslateFn) storage.SampleAndChunkQueryable
func TranslateToPromqlAPIError ¶
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 Config ¶
type Config struct { QueryTimeout time.Duration `yaml:"query_timeout"` 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"` }
Config for a querier.
func DefaultQuerierConfig ¶
func DefaultQuerierConfig() Config
func (*Config) RegisterFlags ¶
RegisterFlags register flags.
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.
type ErrTranslateFn ¶
ErrTranslateFn is used to translate or wrap error before returning it by functions in storage.SampleAndChunkQueryable interface. Input error may be nil.
type IngesterQuerier ¶
type IngesterQuerier struct {
// contains filtered or unexported fields
}
IngesterQuerier helps with querying the ingesters.
func NewIngesterQuerier ¶
func (*IngesterQuerier) GetChunkIDs ¶
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 (q *IngesterQuerier) Series(ctx context.Context, req *logproto.SeriesRequest) ([][]logproto.SeriesIdentifier, error)
func (*IngesterQuerier) Tail ¶
func (q *IngesterQuerier) Tail(ctx context.Context, req *logproto.TailRequest) (map[string]logproto.Querier_TailClient, error)
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 MockDistributor ¶
func (*MockDistributor) LabelNames ¶
func (*MockDistributor) LabelValuesForLabelName ¶
func (*MockDistributor) MetricsForLabelMatchers ¶
func (*MockDistributor) MetricsMetadata ¶
func (m *MockDistributor) MetricsMetadata(ctx context.Context) ([]scrape.MetricMetadata, error)
func (*MockDistributor) QueryExemplars ¶
func (m *MockDistributor) QueryExemplars(ctx context.Context, from, to model.Time, matchers ...[]*labels.Matcher) (*client.ExemplarQueryResponse, error)
func (*MockDistributor) QueryStream ¶
func (m *MockDistributor) QueryStream(ctx context.Context, from, to model.Time, matchers ...*labels.Matcher) (*client.QueryStreamResponse, error)
type Querier ¶
type Querier struct {
// contains filtered or unexported fields
}
Querier handlers queries.
func New ¶
func New(cfg Config, store storage.Store, ingesterQuerier *IngesterQuerier, limits *validation.Overrides) (*Querier, error)
New makes a new Querier.
func (*Querier) Check ¶
func (*Querier) Check(_ context.Context, _ *grpc_health_v1.HealthCheckRequest) (*grpc_health_v1.HealthCheckResponse, error)
Check implements the grpc healthcheck
func (*Querier) InstantQueryHandler ¶
func (q *Querier) InstantQueryHandler(w http.ResponseWriter, r *http.Request)
InstantQueryHandler is a http.HandlerFunc for instant queries.
func (*Querier) Label ¶
func (q *Querier) Label(ctx context.Context, req *logproto.LabelRequest) (*logproto.LabelResponse, error)
Label does the heavy lifting for a Label query.
func (*Querier) LabelHandler ¶
func (q *Querier) LabelHandler(w http.ResponseWriter, r *http.Request)
LabelHandler is a http.HandlerFunc for handling label queries.
func (*Querier) LogQueryHandler ¶
func (q *Querier) LogQueryHandler(w http.ResponseWriter, r *http.Request)
LogQueryHandler is a http.HandlerFunc for log only queries.
func (*Querier) RangeQueryHandler ¶
func (q *Querier) RangeQueryHandler(w http.ResponseWriter, r *http.Request)
RangeQueryHandler is a http.HandlerFunc for range queries.
func (*Querier) SelectLogs ¶
func (q *Querier) SelectLogs(ctx context.Context, params logql.SelectLogParams) (iter.EntryIterator, error)
Select Implements logql.Querier which select logs via matchers and regex filters.
func (*Querier) SelectSamples ¶
func (q *Querier) SelectSamples(ctx context.Context, params logql.SelectSampleParams) (iter.SampleIterator, error)
func (*Querier) Series ¶
func (q *Querier) Series(ctx context.Context, req *logproto.SeriesRequest) (*logproto.SeriesResponse, error)
Series fetches any matching series for a list of matcher sets
func (*Querier) SeriesHandler ¶
func (q *Querier) 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 (*Querier) SetQueryable ¶
func (*Querier) TailHandler ¶
func (q *Querier) TailHandler(w http.ResponseWriter, r *http.Request)
TailHandler is a http.HandlerFunc for handling tail queries.
type QueryResponse ¶
type Tailer ¶
type Tailer struct {
// contains filtered or unexported fields
}
Tailer manages complete lifecycle of a tail request
type TestConfig ¶
type TestConfig struct { Cfg Config Distributor base_querier.Distributor Stores []base_querier.QueryableWithFilter }