mirror of
https://github.com/gravitational/teleport
synced 2024-10-18 16:24:03 +00:00
proxy: add proxy_ssh_sessions_total metric
This is similar to server_interactive_sessions_total, but tracks all SSH sessions through a proxy.
This commit is contained in:
parent
269d0285c3
commit
3004b65019
|
@ -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)
|
||||
})
|
||||
|
|
|
@ -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",
|
||||
},
|
||||
)
|
||||
)
|
||||
|
|
|
@ -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"
|
||||
|
||||
|
|
Loading…
Reference in a new issue