multitenant

package
v0.15.0 Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2026 License: AGPL-3.0 Imports: 17 Imported by: 0

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

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

DetectedLabels merges the per-tenant HyperLogLog sketches and sorts the labels by cardinality.

func (*Index) IndexStats

IndexStats sums the per-tenant statistics.

func (*Index) Patterns

Patterns merges the per-tenant pattern series.

func (*Index) Volume

Volume merges the per-tenant volumes, keeping the request's limit.

type IndexStore

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

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

Series returns series across all tenants, each labelled with __tenant_id__.

type Store

Store is what runakefli's ClickHouse querier offers per tenant: the log/sample selectors plus the label/series metadata endpoints.

Jump to

Keyboard shortcuts

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