diff --git a/lib/srv/regular/proxy.go b/lib/srv/regular/proxy.go index dfa89b02260..b2551388883 100644 --- a/lib/srv/regular/proxy.go +++ b/lib/srv/regular/proxy.go @@ -38,9 +38,21 @@ import ( "github.com/gravitational/trace" "github.com/pborman/uuid" + "github.com/prometheus/client_golang/prometheus" "github.com/sirupsen/logrus" ) +var proxiedSessions = prometheus.NewGauge( + prometheus.GaugeOpts{ + Name: teleport.MetricProxySSHSessions, + Help: "Number of active sessions through this proxy", + }, +) + +func init() { + prometheus.MustRegister(proxiedSessions) +} + // proxySubsys implements an SSH subsystem for proxying listening sockets from // remote hosts to a proxy client (AKA port mapping) type proxySubsys struct { @@ -250,6 +262,7 @@ func (t *proxySubsys) proxyToSite( } t.log.Infof("Connected to auth server: %v", conn.RemoteAddr()) + proxiedSessions.Inc() go func() { var err error defer func() { @@ -424,6 +437,7 @@ func (t *proxySubsys) proxyToHost( // address to the SSH server t.doHandshake(remoteAddr, ch, conn) + proxiedSessions.Inc() go func() { var err error defer func() { @@ -446,6 +460,7 @@ func (t *proxySubsys) proxyToHost( func (t *proxySubsys) close(err error) { t.closeOnce.Do(func() { + proxiedSessions.Dec() t.error = err close(t.closeC) }) diff --git a/lib/srv/sess.go b/lib/srv/sess.go index 2ec9eb598e7..1e426383400 100644 --- a/lib/srv/sess.go +++ b/lib/srv/sess.go @@ -50,7 +50,7 @@ var ( serverSessions = prometheus.NewGauge( prometheus.GaugeOpts{ Name: teleport.MetricServerInteractiveSessions, - Help: "Number of active sessions", + Help: "Number of active sessions to this host", }, ) ) diff --git a/metrics.go b/metrics.go index 2038960ebe4..b37812ef3c8 100644 --- a/metrics.go +++ b/metrics.go @@ -34,6 +34,9 @@ const ( // MetricServerInteractiveSessions measures interactive sessions in flight MetricServerInteractiveSessions = "server_interactive_sessions_total" + // MetricProxySSHSessions measures sessions in flight on the proxy + MetricProxySSHSessions = "proxy_ssh_sessions_total" + // MetricRemoteClusters measures connected remote clusters MetricRemoteClusters = "remote_clusters"