api

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: 45 Imported by: 0

Documentation

Overview

Package api provides the HTTP API handlers for runakefli, serving Loki's endpoints (push, query, series, labels, tail, deletes, rules) over ClickHouse.

Package api query limits.

Copied from grafana/loki@39c256e5 pkg/querier/queryrange/limits.go (validateMaxEntriesLimits, validateMatchers, requiredLabelsErrTmpl, requiredNumberLabelsErrTmpl, maxSeriesErrTmpl), pkg/querier/queryrange/ roundtrip.go (the matcher and entry-limit part of roundTripper.Do), the lookback and length part of pkg/querier/limits/validation.go ValidateQueryTimeRangeLimits, and the matcher-count check of pkg/querier/limits/validation.go ValidateQueryRequest; modifications: the two validate* helpers take the tenant list and the *validation.Overrides as parameters (Loki reads the tenant list from ctx itself); the lookback clamp and the max-query-length check use the smallest positive per-tenant value, as in the single-binary distributor; an entirely-looked-back range returns an empty result instead of an error, as in Loki's roundTripper.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FormatQueryHandler

func FormatQueryHandler() http.HandlerFunc

FormatQueryHandler formats the "query" form value with syntax.Prettify.

Types

type API

type API struct {
	// Queries executes LogQL queries, choosing between the plain engine and
	// the push-down engine.
	Queries Querier
	Q       *chstore.Querier
	// Meta answers label/series for the metadata endpoints. It is nil unless
	// multi-tenant queries are enabled; then it is the multi-tenant querier.
	Meta MetaQuerier
	Push http.Handler
	// Limits configures per-tenant limits.
	Limits *validation.Overrides
	// Metrics, when set, is served on GET /metrics (no tenant).
	Metrics http.Handler
	// Pprof, when true, serves the Go profiler on /debug/pprof/* (no tenant).
	Pprof       bool
	AuthEnabled bool
	Patterns    *patterns.Querier
	Deletes     *deletes.Handler
	Tail        http.Handler
	Rules       *rulerbase.API // Loki's ruler API; nil = ruler disabled
	// Ready, when set, is called by GET /ready; an error answers 503
	// (runakefli is not ready without ClickHouse).
	Ready func(context.Context) error
	// MultiTenant fans the index and drilldown endpoints out per tenant
	// (query.querier.multi_tenant_queries_enabled).
	MultiTenant bool
}

API is the runakefli HTTP API server. It wires together the query, push, delete, tail and ruler handlers into a single http.Handler.

func (*API) Router

func (a *API) Router() http.Handler

Router returns the http.Handler that serves all runakefli API endpoints.

type FormatQueryResponse

type FormatQueryResponse struct {
	Status string `json:"status"`
	Data   string `json:"data,omitempty"`
	Err    string `json:"error,omitempty"`
}

FormatQueryResponse is the JSON body of /loki/api/v1/format_query.

type MetaQuerier

type MetaQuerier interface {
	Label(ctx context.Context, req *logproto.LabelRequest) (*logproto.LabelResponse, error)
	Series(ctx context.Context, req *logproto.SeriesRequest) (*logproto.SeriesResponse, error)
}

MetaQuerier is what the metadata endpoints call: label names/values and series. The plain *chstore.Querier and the multi-tenant querier both satisfy it.

type Querier

type Querier interface {
	Query(ctx context.Context, p logql.Params) logql.Query
}

Querier executes a LogQL query. Both the plain *logql.QueryEngine and the *pushdown.Engine satisfy it via the adapters below.

func NewPlainQuerier

func NewPlainQuerier(e *logql.QueryEngine) Querier

NewPlainQuerier adapts a *logql.QueryEngine to the api.Querier interface.

Jump to

Keyboard shortcuts

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