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.
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.