metrics

package
v0.23.1 Latest Latest
Warning

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

Go to latest
Published: Sep 12, 2026 License: AGPL-3.0 Imports: 11 Imported by: 0

Documentation

Overview

Package metrics provides an HTTP handler for proxying metrics requests to specific upstream endpoints using net/http/httputil.ReverseProxy.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func StartServer

func StartServer(ctx context.Context, port int, handler *ProxyHandler) error

StartServer starts an HTTP server on the specified port with the given ProxyHandler.

Types

type Option added in v0.23.1

type Option func(*ProxyHandler)

Option configures a ProxyHandler.

func WithAppendGatherer added in v0.23.1

func WithAppendGatherer(path string, g prometheus.Gatherer) Option

WithAppendGatherer writes the families of g after the upstream body on path. The upstream is the Envoy admin interface, which does not answer while Envoy restarts. The response then carries only the families of g, so that a scrape still reports whether Envoy runs.

func WithHandler added in v0.23.1

func WithHandler(path string, handler http.Handler) Option

WithHandler answers path with handler instead of proxying it.

type ProxyHandler

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

func NewProxyHandler

func NewProxyHandler(upstreams map[string]string, opts ...Option) *ProxyHandler

NewProxyHandler creates a new ProxyHandler with the given upstreams configuration. The upstreams map keys are request paths and values are upstream URLs. For example: {"/metrics": "127.0.0.1:8000/metrics", "/stats/prometheus": "127.0.0.1:19000/stats/prometheus"}

func (*ProxyHandler) ServeHTTP

func (h *ProxyHandler) ServeHTTP(w http.ResponseWriter, r *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