api

package
v0.0.0-...-a887ba8 Latest Latest
Warning

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

Go to latest
Published: Sep 24, 2026 License: Apache-2.0 Imports: 47 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewPrometheus

func NewPrometheus(
	queryable storage.SampleAndChunkQueryable,
	appendable storage.Appendable,
	maxConcurrent int,
	metricRegistry prometheus.Registerer,
	apiLogger zerolog.Logger,
) *v1.API

NewPrometheus returns a new initialized Prometheus web API. Only remote read/write and PromQL endpoints are implemented. appendable can be empty if remote write is not used.

Types

type API

type API struct {
	ListenAddress string
	Queryable     types.QueryableWithOptions
	Appendable    types.AppendableWithOptions
	// OptionsParser (optional) parses per-request backend options from HTTP headers;
	// DebugEndpoint (optional) exposes the legacy index/flush/pre-aggregate debug
	// operations. Both are backend capabilities, set only when the backend provides
	// them (nil otherwise).
	OptionsParser               types.HTTPOptionsParser
	DebugEndpoint               TSDBDebugEndpoint
	MutableLabelWriter          MutableLabelInterface
	DefaultTTL                  time.Duration
	MaxConcurrentRemoteRequests int
	// MaxRequestBodySizeBytes defines the maximum size of incoming requests body.
	MaxRequestBodySizeBytes  int64
	PromQLMaxEvaluatedPoints uint64
	MetricRegistry           prometheus.Registerer
	PromQLMaxEvaluatedSeries uint32
	TenantLabelName          string
	MutableLabelDetector     requestscoped.MutableLabelDetector
	// When enabled, return an response to queries and write
	// requests that don't provide the tenant header.
	RequireTenantHeader bool
	// BackendDebug, when set, registers backend-specific debug endpoints under
	// /debug/<BackendName>/. BackendName identifies the backend (e.g. "clickhouse")
	// so two backends never collide on the same relative path.
	BackendDebug BackendDebugRegistrar
	BackendName  string
	Logger       zerolog.Logger

	FuturePointsBackdateOffset time.Duration
	// contains filtered or unexported fields
}

API it the SquirrelDB HTTP API server.

func (*API) ListenPort

func (a *API) ListenPort() int

ListenPort return the port listenning on. Should not be used before Run() signalled its readiness. This is useful for tests that use port "0" to known the actual listenning port.

func (*API) Ready

func (a *API) Ready()

Ready mark the system as ready to access requests.

func (*API) Run

func (a *API) Run(ctx context.Context, readiness chan error)

Run start the HTTP api server.

func (*API) ServeHTTP

func (a *API) ServeHTTP(w http.ResponseWriter, req *http.Request)

type BackendDebugRegistrar

type BackendDebugRegistrar interface {
	RegisterHTTPEndpoints(register func(method, path, description string, handler http.HandlerFunc))
}

BackendDebugRegistrar is implemented by the storage backend to register its debug HTTP endpoints. The API calls it with a register function that prepends /debug/<BackendName>/ to each (relative) path; the description feeds the /debug/ index.

type MutableLabelInterface

type MutableLabelInterface interface {
	WriteLabelValues(ctx context.Context, lbls []mutable.LabelWithValues) error
	DeleteLabelValues(ctx context.Context, lbls []mutable.Label) error
	WriteLabelNames(ctx context.Context, lbls []mutable.LabelWithName) error
	DeleteLabelNames(ctx context.Context, names []mutable.LabelKey) error
	Dump(ctx context.Context, w io.Writer) error
	Import(ctx context.Context, r io.Reader, w io.Writer, dryRun bool) error
}

type TSDBDebugEndpoint

type TSDBDebugEndpoint interface {
	ForcePreAggregation(
		ctx context.Context,
		threadCount int,
		from time.Time,
		to time.Time,
		matchers []*labels.Matcher,
	) error
	Flush(ctx context.Context) error
	Index() types.Index
}

TSDBDebugEndpoint define the (legacy) troubleshooting endpoints exposed by API. Because newer backend/tsdb might not implement thing the same way (e.g. no index), This should be deprecated and replaced by another approch.

Directories

Path Synopsis
Package requestscoped implements features that rely on HTTP request headers, like applying tenant limitation, per-request limit of evaluated points/series, ...
Package requestscoped implements features that rely on HTTP request headers, like applying tenant limitation, per-request limit of evaluated points/series, ...

Jump to

Keyboard shortcuts

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