proxy

package
v1.1.4 Latest Latest
Warning

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

Go to latest
Published: Feb 27, 2025 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FormatQuery

func FormatQuery(query string) (string, error)

FormatQuery formats the given query.

func GetMatchExpr

func GetMatchExpr(matchers []*labels.Matcher) string

GetMatchExpr returns the string representation of the given matchers in the form of a Prometheus match expression.

func RewriteQuery

func RewriteQuery(query string, extraMatchers []*labels.Matcher) (string, error)

RewriteQuery rewrites the given query with the given extra matchers.

Types

type Proxy

type Proxy struct {
	// contains filtered or unexported fields
}

Proxy is an HTTP handler that proxies requests to a Prometheus instance.

func NewProxy

func NewProxy(upstreamEndpoint string, upstreamClient *http.Client, keys []string, labelMatchers []*labels.Matcher) *Proxy

NewProxy creates a new Proxy. Arguments explained:

  • The upstreamEndpoint is the URL of the upstream Prometheus instance.
  • The upstreamClient is used to proxy requests to the upstream Prometheus instance.
  • The keys are used to provide virtual sub-routes for the proxy. For example, if the keys are ["namespace", "pod"], and the request path is "/{namespace}/{pod}/api/v1/query", the key-values will be ["{namespace}", "{pod}"]. The key-values are then converted to label matchers and appended to the label matchers provided in the configuration. In this example, the label matchers will be {namespace="{namespace}", pod="{pod}"}. If the keys are empty, no virtual sub-routes are provided. The proxy will only handle the root path, e.g., "/api/v1/query".
  • The labelMatchers are the label matchers to apply to all queries.

func (*Proxy) ServeHTTP

func (p *Proxy) ServeHTTP(writer http.ResponseWriter, request *http.Request)

ServeHTTP implements the http.Handler interface.

Jump to

Keyboard shortcuts

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