grafana / k8s-monitoring-helm

Apache License 2.0
194 stars 77 forks source link

Add proxy support for Tempo and OpenCost #193

Open petewall opened 12 months ago

petewall commented 12 months ago

Original slack thread

Tempo

Proxy configuration appears to be done via the *nix environment variables (such as HTTPS_PROXY), according to the docs: https://grafana.com/docs/agent/latest/flow/reference/components/otelcol.exporter.otlp/

To maintain compatibility with k8s service discovery, NO_PROXY should be used to exclude the API server, e.g.:

grafana-agent:
  agent:
    extraEnv:
    - name: HTTPS_PROXY
      value: https://proxy.example.com/
    - name: NO_PROXY
      value: <cluster.kubernetesAPIService, maybe without port>
petewall commented 11 months ago

OpenCost also uses Golang's http.ProxyFromEnvironment:

// ProxyFromEnvironment returns the URL of the proxy to use for a
// given request, as indicated by the environment variables
// HTTP_PROXY, HTTPS_PROXY and NO_PROXY (or the lowercase versions
// thereof). Requests use the proxy from the environment variable
// matching their scheme, unless excluded by NO_PROXY.
//
// The environment values may be either a complete URL or a
// "host[:port]", in which case the "http" scheme is assumed.
// The schemes "http", "https", and "socks5" are supported.
// An error is returned if the value is a different form.
//
// A nil URL and nil error are returned if no proxy is defined in the
// environment, or a proxy should not be used for the given request,
// as defined by NO_PROXY.
//
// As a special case, if req.URL.Host is "localhost" (with or without
// a port number), then a nil URL and nil error will be returned.
func ProxyFromEnvironment(req *Request) (*url.URL, error) {
    return envProxyFunc()(req.URL)
}
petewall commented 11 months ago

The nice thing w.r.t. OpenCost, is that it shouldn't interfere with Grafana Agent connections.