From d037f6fb70269879abe438e64b84a55cb8f57234 Mon Sep 17 00:00:00 2001 From: ale <ale@incal.net> Date: Thu, 4 Feb 2021 09:19:00 +0000 Subject: [PATCH] Add a metric for the total number of proxied connections It should allow us to tell apart SSL and non-SSL connections. --- node/instrumentation.go | 7 +++++++ node/proxy.go | 2 ++ 2 files changed, 9 insertions(+) diff --git a/node/instrumentation.go b/node/instrumentation.go index ce43213f..6b57e7a4 100644 --- a/node/instrumentation.go +++ b/node/instrumentation.go @@ -37,6 +37,13 @@ var ( }, []string{"stream", "upstream"}, ) + proxyConnections = prometheus.NewCounterVec( + prometheus.CounterOpts{ + Name: "proxy_connections_total", + Help: "Proxy connections.", + }, + []string{"proto"}, + ) // Node metrics. icecastUpdateFailed = prometheus.NewGauge( diff --git a/node/proxy.go b/node/proxy.go index 4ac131f8..593077c6 100644 --- a/node/proxy.go +++ b/node/proxy.go @@ -107,12 +107,14 @@ func doIcecastProxy(rw http.ResponseWriter, req *http.Request, target *url.URL, // httputil.ReverseProxy (not fully functional for sources, but // meh). if req.TLS != nil { + proxyConnections.WithLabelValues("https").Inc() u := *outreq.URL u.Path = "/" rp := httputil.NewSingleHostReverseProxy(&u) rp.ServeHTTP(rw, outreq) return } + proxyConnections.WithLabelValues("http").Inc() // Create the upstream connection and write the HTTP request // to it. -- GitLab