prometheus

package
v2.0.4 Latest Latest
Warning

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

Go to latest
Published: Jul 3, 2026 License: Apache-2.0 Imports: 38 Imported by: 0

Documentation

Overview

Package prometheus provides the Prometheus Backend provider

Index

Constants

View Source
const (
	APIPath = "/api/v1/"
)

Prometheus API

Variables

This section is empty.

Functions

func MergeablePaths

func MergeablePaths() []string

MergeablePaths returns the list of Prometheus Paths for which Trickster supports merging multiple documents into a single response

func NewClient

func NewClient(name string, o *bo.Options, router http.Handler,
	cache cache.Cache, _ backends.Backends,
	_ types.Lookup,
) (backends.Backend, error)

NewClient returns a new Client Instance

Types

type Client

type Client struct {
	backends.TimeseriesBackend
	// contains filtered or unexported fields
}

Client Implements Proxy Client Interface

func (*Client) AlertsHandler

func (c *Client) AlertsHandler(w http.ResponseWriter, r *http.Request)

AlertsHandler proxies requests for path /alerts to the origin by way of the object proxy cache

func (*Client) ClassifyMerge added in v2.0.2

func (c *Client) ClassifyMerge(query string) (strategy int, needsDualQuery bool, warning string)

ClassifyMerge implements backends.TSMMergeProvider for the Prometheus backend. It inspects the outermost PromQL aggregation operator and returns the merge strategy (as the int value of dataset.MergeStrategy), whether a dual-query weighted average is required, and an optional warning for operators whose results cannot be correctly merged across shards.

func (*Client) DefaultHealthCheckConfig

func (c *Client) DefaultHealthCheckConfig() *ho.Options

DefaultHealthCheckConfig returns the default HealthCheck Config for this backend provider

func (*Client) DefaultPathConfigs

func (c *Client) DefaultPathConfigs(o *bo.Options) po.List

DefaultPathConfigs returns the default PathConfigs for the given Provider

func (*Client) FastForwardRequest

func (c *Client) FastForwardRequest(r *http.Request) (*http.Request, error)

FastForwardRequest returns an *http.Request crafted to collect Fast Forward data from the Origin, based on the provided HTTP Request

func (*Client) FinalizeTSMMerge added in v2.0.3

func (c *Client) FinalizeTSMMerge(query string, ts timeseries.Timeseries)

FinalizeTSMMerge applies Prometheus-only merge finalization after TSM fanout has accumulated the rewritten inner-query responses. The rank step belongs here so topk/bottomk operate on globally merged values, not per-backend ranks.

func (*Client) LabelsHandler

func (c *Client) LabelsHandler(w http.ResponseWriter, r *http.Request)

LabelsHandler proxies requests for path /label and /labels to the origin by way of the object proxy cache

func (*Client) MergeablePaths

func (c *Client) MergeablePaths() []string

MergeablePaths returns the list of Prometheus Paths for which Trickster supports merging multiple documents into a single response

func (*Client) ObjectProxyCacheHandler

func (c *Client) ObjectProxyCacheHandler(w http.ResponseWriter, r *http.Request)

ObjectProxyCacheHandler handles calls to /query (for instantaneous values)

func (*Client) ParseTimeRangeQuery

func (c *Client) ParseTimeRangeQuery(r *http.Request) (*timeseries.TimeRangeQuery,
	*timeseries.RequestOptions, bool, error,
)

ParseTimeRangeQuery parses the key parts of a TimeRangeQuery from the inbound HTTP Request

func (*Client) ProcessTransformations

func (c *Client) ProcessTransformations(ts timeseries.Timeseries)

func (*Client) ProxyHandler

func (c *Client) ProxyHandler(w http.ResponseWriter, r *http.Request)

ProxyHandler sends a request through the basic reverse proxy to the origin, and services non-cacheable Prometheus API calls.

func (*Client) QueryHandler

func (c *Client) QueryHandler(w http.ResponseWriter, r *http.Request)

QueryHandler handles calls to /query (for instantaneous values)

func (*Client) QueryRangeHandler

func (c *Client) QueryRangeHandler(w http.ResponseWriter, r *http.Request)

QueryRangeHandler handles timeseries requests for Prometheus and processes them through the delta proxy cache

func (*Client) RegisterHandlers

func (c *Client) RegisterHandlers(handlers.Lookup)

func (*Client) RewriteForTSMMerge added in v2.0.3

func (c *Client) RewriteForTSMMerge(r *http.Request, query string) (*http.Request, string)

RewriteForTSMMerge rewrites Prometheus rank aggregations before TSM fanout. The shards receive the inner query; FinalizeTSMMerge later applies the original topk/bottomk operation to the merged inner result.

func (*Client) RewriteForWeightedAvg added in v2.0.2

func (c *Client) RewriteForWeightedAvg(r *http.Request, query string) (*http.Request, *http.Request)

RewriteForWeightedAvg implements backends.TSMMergeProvider for the Prometheus backend. It returns two copies of r — one with the outer "avg" aggregator replaced by "sum" and one by "count" — with the rewritten expression injected into the Prometheus "query" parameter. Both GET (query string) and POST (request body) encodings are handled transparently by params.SetRequestValues.

func (*Client) SeriesHandler

func (c *Client) SeriesHandler(w http.ResponseWriter, r *http.Request)

SeriesHandler proxies requests for path /series to the origin by way of the object proxy cache

func (*Client) SetExtent

func (c *Client) SetExtent(r *http.Request, _ *timeseries.TimeRangeQuery,
	extent *timeseries.Extent,
)

SetExtent will change the upstream request query to use the provided Extent

func (*Client) UnsupportedHandler

func (c *Client) UnsupportedHandler(w http.ResponseWriter, _ *http.Request)

UnsupportedHandler responds to endpoints like /api/v1/admin

Directories

Path Synopsis
Package promql provides utilities for parsing and rewriting PromQL queries.
Package promql provides utilities for parsing and rewriting PromQL queries.

Jump to

Keyboard shortcuts

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