Documentation
¶
Overview ¶
Package multitenant lets a single runakefli instance answer queries whose X-Scope-OrgID names several tenants ("a|b"): one sub-query per tenant, each result labelled with __tenant_id__, merged the way Loki's multi-tenant querier does.
Copied from grafana/loki@39c256e5 pkg/querier/multi_tenant_querier.go (SelectLogs, SelectSamples, Label, Series, removeTenantSelector, replaceMatchers, filterValuesByMatchers, sliceToSet, relabel and the defaultTenantLabel/retainExistingPrefix constants); modifications: wraps runakefli's Store instead of Loki's querier.Querier; the store-chunk overrides (partitionChunkRefsByTenant) are omitted because runakefli has no chunks; SelectLogs closes the iterators it opened when a later tenant fails, as Loki's SelectSamples does. index.go fans out the index and drilldown endpoints (IndexStats, Volume, Patterns, DetectedLabels) the same way.
Index ¶
- type Index
- func (q *Index) DetectedLabels(ctx context.Context, req *logproto.DetectedLabelsRequest) (*logproto.DetectedLabelsResponse, error)
- func (q *Index) IndexStats(ctx context.Context, req *logproto.IndexStatsRequest) (*logproto.IndexStatsResponse, error)
- func (q *Index) Patterns(ctx context.Context, req *logproto.QueryPatternsRequest) (*logproto.QueryPatternsResponse, error)
- func (q *Index) Volume(ctx context.Context, req *logproto.VolumeRequest) (*logproto.VolumeResponse, error)
- type IndexStore
- type Querier
- func (q *Querier) Label(ctx context.Context, req *logproto.LabelRequest) (*logproto.LabelResponse, error)
- func (q *Querier) SelectLogs(ctx context.Context, params logql.SelectLogParams) (_ iter.EntryIterator, returnErr error)
- func (q *Querier) SelectSamples(ctx context.Context, params logql.SelectSampleParams) (_ iter.SampleIterator, returnErr error)
- func (q *Querier) Series(ctx context.Context, req *logproto.SeriesRequest) (*logproto.SeriesResponse, error)
- type Store
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Index ¶
type Index struct {
Next IndexStore
}
Index answers the index and drilldown endpoints for an X-Scope-OrgID naming several tenants: one call per tenant, merged as Loki merges them. A single tenant passes straight through (Volume always merges, as in Loki).
func (*Index) DetectedLabels ¶
func (q *Index) DetectedLabels(ctx context.Context, req *logproto.DetectedLabelsRequest) (*logproto.DetectedLabelsResponse, error)
DetectedLabels merges the per-tenant HyperLogLog sketches and sorts the labels by cardinality.
func (*Index) IndexStats ¶
func (q *Index) IndexStats(ctx context.Context, req *logproto.IndexStatsRequest) (*logproto.IndexStatsResponse, error)
IndexStats sums the per-tenant statistics.
func (*Index) Patterns ¶
func (q *Index) Patterns(ctx context.Context, req *logproto.QueryPatternsRequest) (*logproto.QueryPatternsResponse, error)
Patterns merges the per-tenant pattern series.
func (*Index) Volume ¶
func (q *Index) Volume(ctx context.Context, req *logproto.VolumeRequest) (*logproto.VolumeResponse, error)
Volume merges the per-tenant volumes, keeping the request's limit.
type IndexStore ¶
type IndexStore interface {
IndexStats(ctx context.Context, req *logproto.IndexStatsRequest) (*logproto.IndexStatsResponse, error)
Volume(ctx context.Context, req *logproto.VolumeRequest) (*logproto.VolumeResponse, error)
DetectedLabels(ctx context.Context, req *logproto.DetectedLabelsRequest) (*logproto.DetectedLabelsResponse, error)
Patterns(ctx context.Context, req *logproto.QueryPatternsRequest) (*logproto.QueryPatternsResponse, error)
}
IndexStore answers the index and drilldown endpoints for the single tenant in the context.
type Querier ¶
type Querier struct {
Next Store
}
Querier answers queries whose X-Scope-OrgID names several tenants ("a|b"): one sub-query per tenant, each result labelled __tenant_id__. Single-tenant requests pass straight through to Next.
func (*Querier) Label ¶
func (q *Querier) Label(ctx context.Context, req *logproto.LabelRequest) (*logproto.LabelResponse, error)
Label returns label names/values across all tenants, adding __tenant_id__ to the name list and special-casing its values.
func (*Querier) SelectLogs ¶
func (q *Querier) SelectLogs(ctx context.Context, params logql.SelectLogParams) (_ iter.EntryIterator, returnErr error)
SelectLogs fans out to Next per tenant, wrapping each iterator so every stream is labelled with its tenant, and merges them in the requested order.
func (*Querier) SelectSamples ¶
func (q *Querier) SelectSamples(ctx context.Context, params logql.SelectSampleParams) (_ iter.SampleIterator, returnErr error)
SelectSamples fans out to Next per tenant and merges by the requested order.
func (*Querier) Series ¶
func (q *Querier) Series(ctx context.Context, req *logproto.SeriesRequest) (*logproto.SeriesResponse, error)
Series returns series across all tenants, each labelled with __tenant_id__.
type Store ¶
type Store interface {
logql.Querier
Label(ctx context.Context, req *logproto.LabelRequest) (*logproto.LabelResponse, error)
Series(ctx context.Context, req *logproto.SeriesRequest) (*logproto.SeriesResponse, error)
}
Store is what runakefli's ClickHouse querier offers per tenant: the log/sample selectors plus the label/series metadata endpoints.